diff --git a/lib/cs/diagnosticMessages.generated.json b/lib/cs/diagnosticMessages.generated.json index e5e989e6679..32a067f4fe8 100644 --- a/lib/cs/diagnosticMessages.generated.json +++ b/lib/cs/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Deklarace oboru názvů nemůže být umístěná před třídou nebo funkcí, se kterou se slučuje.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Deklarace oboru názvů je povolená jenom v oboru názvů nebo v modulu.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Import stylu oboru názvů není možné vyvolat nebo konstruovat a způsobí selhání za běhu.", - "A_non_dry_build_would_build_project_0_6357": "Build nedodržující princip DRY by vytvořil projekt {0}.", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Build nedodržující princip DRY by odstranil následující soubory: {0}", + "A_non_dry_build_would_build_project_0_6357": "Build bez příznaku -dry by vytvořil projekt {0}.", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Build bez příznaku -dry by odstranil následující soubory: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Inicializátor parametru je povolený jenom v implementaci funkce nebo konstruktoru.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Vlastnost parametru se nedá deklarovat pomocí parametru rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Vlastnost parametru je povolená jenom v implementaci konstruktoru.", diff --git a/lib/de/diagnosticMessages.generated.json b/lib/de/diagnosticMessages.generated.json index 99b3594c8f7..afb8baa15b6 100644 --- a/lib/de/diagnosticMessages.generated.json +++ b/lib/de/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Eine Namespacedeklaration darf nicht vor der Klasse oder Funktion positioniert werden, mit der sie zusammengeführt wird.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Eine Namespacedeklaration ist nur in einem Namespace oder Modul zulässig.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Ein Import im Namespacestil kann nicht aufgerufen oder erstellt werden und verursacht zur Laufzeit einen Fehler.", - "A_non_dry_build_would_build_project_0_6357": "Bei einem echten Build würde das Projekt \"{0}\" erstellt.", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Bei einem echten Build würden die folgenden Dateien gelöscht: {0}", + "A_non_dry_build_would_build_project_0_6357": "Bei einem Build mit dem Flag \"-dry\" würde das Projekt \"{0}\" erstellt.", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Bei einem Build mit dem Flag \"-dry\" würden die folgenden Dateien gelöscht: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Ein Parameterinitialisierer ist nur in einer Funktions- oder Konstruktorimplementierung zulässig.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Eine Parametereigenschaft darf nicht mithilfe eines rest-Parameters deklariert werden.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Eine Parametereigenschaft ist nur in einer Konstruktorimplementierung zulässig.", diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg index 7199fab2a52..185925b4fae 100644 --- a/lib/enu/diagnosticMessages.generated.json.lcg +++ b/lib/enu/diagnosticMessages.generated.json.lcg @@ -363,6 +363,12 @@ + + + + + + @@ -393,6 +399,18 @@ + + + + + + + + + + + + @@ -495,12 +513,6 @@ - - - - - - @@ -603,6 +615,12 @@ + + + + + + @@ -657,6 +675,12 @@ + + + + + + @@ -1683,6 +1707,12 @@ + + + + + + @@ -1743,6 +1773,12 @@ + + + + + + @@ -1755,6 +1791,12 @@ + + + + + + @@ -1869,6 +1911,12 @@ + + + + + + @@ -2805,6 +2853,12 @@ + + + + + + @@ -3405,9 +3459,9 @@ - + - + @@ -4203,6 +4257,12 @@ + + + + + + @@ -4257,6 +4317,12 @@ + + + + + + @@ -4593,6 +4659,12 @@ + + + + + + @@ -5109,6 +5181,18 @@ + + + + + + + + + + + + @@ -5355,6 +5439,12 @@ + + + + + + @@ -5619,6 +5709,12 @@ + + + + + + @@ -6177,6 +6273,18 @@ + + + + + + + + + + + + @@ -6189,6 +6297,12 @@ + + + + + + diff --git a/lib/es/diagnosticMessages.generated.json b/lib/es/diagnosticMessages.generated.json index 7ff3b1ecfc2..0e0e31a2b11 100644 --- a/lib/es/diagnosticMessages.generated.json +++ b/lib/es/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Una declaración de espacio de nombres no se puede situar antes que una clase o función con la que se combina.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Una declaración de espacio de nombres solo se permite en un espacio de nombres o en un módulo.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "No se puede llamar o construir una importación de estilo de espacio de nombres, y provocará un error en tiempo de ejecución.", - "A_non_dry_build_would_build_project_0_6357": "Una compilación no DRY compilaría el proyecto \"{0}\"", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Una compilación no DRY eliminaría los siguientes archivos: {0}", + "A_non_dry_build_would_build_project_0_6357": "Una compilación no -dry compilaría el proyecto \"{0}\"", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Una compilación no -dry eliminaría los archivos siguientes: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Un inicializador de parámetros solo se permite en una implementación de función o de constructor.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Una propiedad de parámetro no se puede declarar mediante un parámetro rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Una propiedad de parámetro solo se permite en una implementación de constructor.", diff --git a/lib/fr/diagnosticMessages.generated.json b/lib/fr/diagnosticMessages.generated.json index f8443633953..1699b44df8b 100644 --- a/lib/fr/diagnosticMessages.generated.json +++ b/lib/fr/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Une déclaration d'espace de noms ne peut pas se trouver avant une classe ou une fonction avec laquelle elle est fusionnée.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Une déclaration d'espace de noms est autorisée uniquement dans un espace de noms ou un module.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Impossible d'appeler ou de construire une importation de style d'espace de noms, ce qui va entraîner un échec au moment de l'exécution.", - "A_non_dry_build_would_build_project_0_6357": "Une build non-DRY générerait le projet '{0}'", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Une build non-DRY supprimerait les fichiers suivants : {0}", + "A_non_dry_build_would_build_project_0_6357": "Une build non-dry va générer le projet '{0}'", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Une build non-dry va supprimer les fichiers suivants : {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Un initialiseur de paramètre est uniquement autorisé dans une implémentation de fonction ou de constructeur.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Impossible de déclarer une propriété de paramètre à l'aide d'un paramètre rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Une propriété de paramètre est uniquement autorisée dans une implémentation de constructeur.", diff --git a/lib/it/diagnosticMessages.generated.json b/lib/it/diagnosticMessages.generated.json index ac6e8d9335a..9f8ef7d48f4 100644 --- a/lib/it/diagnosticMessages.generated.json +++ b/lib/it/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Una dichiarazione di spazio dei nomi non può essere specificata prima di una classe o funzione con cui è stato eseguito il merge.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Una dichiarazione di spazio dei nomi è consentita solo in uno spazio dei nomi o in un modulo.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Non è possibile chiamare o costruire un'importazione in stile spazio dei nomi. Questo comporterà un errore in fase di runtime.", - "A_non_dry_build_would_build_project_0_6357": "Se si esegue una compilazione non di prova, verrà compilato il progetto '{0}'", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Se si esegue una compilazione non di prova, i file seguenti verranno eliminati: {0}", + "A_non_dry_build_would_build_project_0_6357": "Se si esegue una compilazione senza flag -dry, verrà compilato il progetto '{0}'", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Se si esegue una compilazione senza flag -dry, i file seguenti verranno eliminati: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Un inizializzatore di parametro è consentito solo in un'implementazione di funzione o costruttore.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Non è possibile dichiarare una proprietà di parametro usando un parametro REST.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Una proprietà di parametro è consentita solo in un'implementazione di costruttore.", diff --git a/lib/ja/diagnosticMessages.generated.json b/lib/ja/diagnosticMessages.generated.json index 846237d617d..6877a89c753 100644 --- a/lib/ja/diagnosticMessages.generated.json +++ b/lib/ja/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "名前空間宣言は、それとマージするクラスや関数より前に配置できません。", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "名前空間宣言は、名前空間かモジュールでのみ使用できます。", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "名前空間スタイルのインポートを呼び出したり、構築したりすることはできません。実行時にエラーが発生する原因となります。", - "A_non_dry_build_would_build_project_0_6357": "非ドライ ビルドはプロジェクト '{0}' をビルドします", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非ドライ ビルドは、次のファイルを削除します: {0}", + "A_non_dry_build_would_build_project_0_6357": "非 -dry ビルドを実行した場合、プロジェクト '{0}' がビルドされます", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 -dry ビルドを実行した場合、次のファイルが削除されます: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "パラメーター初期化子は、関数またはコンストラクターの実装でのみ指定できます。", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "パラメーター プロパティは、rest パラメーターを使用して宣言することはできません。", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "パラメーター プロパティは、コンストラクターの実装でのみ指定できます。", diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index e695f8ccb6c..c5d6cf984db 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "네임스페이스 선언은 해당 선언이 병합된 클래스나 함수 앞에 있을 수 없습니다.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "네임스페이스 선언은 네임스페이스 또는 모듈에서만 사용할 수 있습니다.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "네임스페이스 스타일 가져오기를 호출하거나 생성할 수 없으며 런타임 시 오류가 발생합니다.", - "A_non_dry_build_would_build_project_0_6357": "DRY가 아닌 빌드는 프로젝트 '{0}'을(를) 빌드합니다.", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "DRY가 아닌 빌드는 다음 파일을 삭제합니다. {0}", + "A_non_dry_build_would_build_project_0_6357": "-dry가 아닌 빌드는 프로젝트 '{0}'을(를) 빌드합니다.", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "-dry가 아닌 빌드는 다음 파일을 삭제합니다. {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "매개 변수 이니셜라이저는 함수 또는 생성자 구현에서만 허용됩니다.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "rest 매개 변수를 사용하여 매개 변수 속성을 선언할 수 없습니다.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "매개 변수 속성은 생성자 구현에서만 허용됩니다.", diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index a6bb70e1023..c6a02b32cc2 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -29,8 +29,7 @@ interface Map { } interface MapConstructor { - new (): Map; - new (entries?: ReadonlyArray<[K, V]> | null): Map; + new (entries?: ReadonlyArray<[K, V]> | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; @@ -50,8 +49,7 @@ interface WeakMap { } interface WeakMapConstructor { - new (): WeakMap; - new (entries?: ReadonlyArray<[K, V]> | null): WeakMap; + new (entries?: ReadonlyArray<[K, V]> | null): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -66,8 +64,7 @@ interface Set { } interface SetConstructor { - new (): Set; - new (values?: ReadonlyArray | null): Set; + new (values?: ReadonlyArray | null): Set; readonly prototype: Set; } declare var Set: SetConstructor; @@ -85,8 +82,7 @@ interface WeakSet { } interface WeakSetConstructor { - new (): WeakSet; - new (values?: ReadonlyArray | null): WeakSet; + new (values?: ReadonlyArray | null): WeakSet; readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index a5fb5671d81..793f587059b 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -155,7 +155,7 @@ interface MapConstructor { interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { @@ -203,7 +203,7 @@ interface SetConstructor { interface WeakSet { } interface WeakSetConstructor { - new (iterable: Iterable): WeakSet; + new (iterable: Iterable): WeakSet; } interface Promise { } diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index f06f588f540..8e8592bd61a 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -22,3 +22,4 @@ and limitations under the License. /// /// /// +/// diff --git a/lib/lib.esnext.intl.d.ts b/lib/lib.esnext.intl.d.ts new file mode 100644 index 00000000000..73a45eedf20 --- /dev/null +++ b/lib/lib.esnext.intl.d.ts @@ -0,0 +1,32 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + + + +/// + + +declare namespace Intl { + type NumberFormatPartTypes = "currency" | "decimal" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign"; + + interface NumberFormatPart { + type: NumberFormatPartTypes; + value: string; + } + + interface NumberFormat { + formatToParts(number?: number): NumberFormatPart[]; + } + } diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index c5b17f60560..bfab76b80ab 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Deklaracja przestrzeni nazw nie może występować przed klasą lub funkcją, z którą ją scalono.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Deklaracja przestrzeni nazw jest dozwolona tylko w przestrzeni nazw lub module.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Nie można wywołać lub skonstruować importu stylu przestrzeni nazw. Spowoduje to błąd w czasie wykonania.", - "A_non_dry_build_would_build_project_0_6357": "Kompilacja inna niż DRY spowodowałaby skompilowanie projektu „{0}”", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Kompilacja inna niż DRY spowodowałaby usunięcie następujących plików: {0}", + "A_non_dry_build_would_build_project_0_6357": "Kompilacja inna niż -dry spowodowałaby skompilowanie projektu „{0}”", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Kompilacja inna niż -dry spowodowałaby usunięcie następujących plików: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Inicjator parametru jest dozwolony tylko w implementacji funkcji lub konstruktora.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Właściwości parametru nie można zadeklarować za pomocą parametru rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Właściwość parametru jest dozwolona tylko w implementacji konstruktora.", diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index cd239619457..1500a9b5987 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -9,7 +9,9 @@ declare namespace ts.server.protocol { GetSpanOfEnclosingComment = "getSpanOfEnclosingComment", Change = "change", Close = "close", + /** @deprecated Prefer CompletionInfo -- see comment on CompletionsResponse */ Completions = "completions", + CompletionInfo = "completionInfo", CompletionDetails = "completionEntryDetails", CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList", CompileOnSaveEmitFile = "compileOnSaveEmitFile", @@ -464,7 +466,8 @@ declare namespace ts.server.protocol { command: CommandTypes.GetEditsForFileRename; arguments: GetEditsForFileRenameRequestArgs; } - interface GetEditsForFileRenameRequestArgs extends FileRequestArgs { + /** Note: Paths may also be directories. */ + interface GetEditsForFileRenameRequestArgs { readonly oldFilePath: string; readonly newFilePath: string; } @@ -1343,6 +1346,10 @@ declare namespace ts.server.protocol { * Optional prefix to apply to possible completions. */ prefix?: string; + /** + * Character that was responsible for triggering completion. + * Should be `undefined` if a user manually requested completion. + */ triggerCharacter?: CompletionsTriggerCharacter; /** * @deprecated Use UserPreferences.includeCompletionsForModuleExports @@ -1485,9 +1492,19 @@ declare namespace ts.server.protocol { */ source?: SymbolDisplayPart[]; } + /** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */ interface CompletionsResponse extends Response { body?: CompletionEntry[]; } + interface CompletionInfoResponse extends Response { + body?: CompletionInfo; + } + interface CompletionInfo { + readonly isGlobalCompletion: boolean; + readonly isMemberCompletion: boolean; + readonly isNewIdentifierLocation: boolean; + readonly entries: ReadonlyArray; + } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } @@ -1570,10 +1587,50 @@ declare namespace ts.server.protocol { */ argumentCount: number; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; /** * Arguments of a signature help request. */ interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + /** + * Reason why signature help was invoked. + * See each individual possible + */ + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; } /** * Signature help request; value of command field is "signatureHelp". @@ -1733,11 +1790,16 @@ declare namespace ts.server.protocol { } /** * Represents additional spans returned with a diagnostic which are relevant to it - * Like DiagnosticWithLinePosition, this is provided in two forms: - * - start and length of the span - * - startLocation and endLocation a pair of Location objects storing the start/end line offset of the span */ interface DiagnosticRelatedInformation { + /** + * The category of the related information message, e.g. "error", "warning", or "suggestion". + */ + category: string; + /** + * The code used ot identify the related information + */ + code: number; /** * Text of related or additional information. */ @@ -1897,7 +1959,7 @@ declare namespace ts.server.protocol { /** * An item found in a navto response. */ - interface NavtoItem { + interface NavtoItem extends FileSpan { /** * The symbol's name. */ @@ -1909,27 +1971,15 @@ declare namespace ts.server.protocol { /** * exact, substring, or prefix. */ - matchKind?: string; + matchKind: string; /** * If this was a case sensitive or insensitive match. */ - isCaseSensitive?: boolean; + isCaseSensitive: boolean; /** * Optional modifiers for the kind (such as 'public'). */ kindModifiers?: string; - /** - * The file in which the symbol is found. - */ - file: string; - /** - * The location within file at which the symbol is found. - */ - start: Location; - /** - * One past the last character of the symbol. - */ - end: Location; /** * Name of symbol's container symbol (if any); for example, * the class name if symbol is a class member. diff --git a/lib/pt-br/diagnosticMessages.generated.json b/lib/pt-br/diagnosticMessages.generated.json index abae5e7a64f..86442c17640 100644 --- a/lib/pt-br/diagnosticMessages.generated.json +++ b/lib/pt-br/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Uma declaração de namespace não pode estar localizada antes de uma classe ou função com a qual ela é mesclada.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Uma declaração de namespace só é permitida e um namespace ou módulo.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Uma importação de estilo do namespace não pode ser chamada nem construída e causará uma falha no tempo de execução.", - "A_non_dry_build_would_build_project_0_6357": "Um build não dry compilaria o projeto '{0}'", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Um build não dry excluiria os seguintes arquivos: {0}", + "A_non_dry_build_would_build_project_0_6357": "Um build não -dry compilaria o projeto '{0}'", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Um build não -dry excluiria os seguintes arquivos: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Um inicializador de parâmetro só é permitido em uma implementação de função ou de construtor.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Uma propriedade de parâmetro não pode ser declarada usando um parâmetro rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Uma propriedade de parâmetro somente é permitida em uma implementação de construtor.", diff --git a/lib/ru/diagnosticMessages.generated.json b/lib/ru/diagnosticMessages.generated.json index 1da5b76d7a9..90d11ced277 100644 --- a/lib/ru/diagnosticMessages.generated.json +++ b/lib/ru/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Объявление пространства имен не может располагаться раньше класса или функции, с которыми оно объединено.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Объявление пространства имен разрешено использовать только в пространстве имен или модуле.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Импорт стиля пространства имен не может быть вызван или создан и приведет к сбою во время выполнения.", - "A_non_dry_build_would_build_project_0_6357": "При выполнении сборки в рабочем режиме будет собран проект \"{0}\"", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "При выполнении сборки в рабочем режиме будут удалены следующие файлы: {0}", + "A_non_dry_build_would_build_project_0_6357": "При сборке без флага -dry будет собран проект \"{0}\"", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "При сборке без флага -dry будут удалены следующие файлы: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Инициализатор параметра разрешено использовать только в реализации функции или конструктора.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Свойство параметра невозможно объявить с помощью параметра REST.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Свойство параметра допускается только в реализации конструктора.", diff --git a/lib/tr/diagnosticMessages.generated.json b/lib/tr/diagnosticMessages.generated.json index cbfdb9d0027..611ccb3a4ad 100644 --- a/lib/tr/diagnosticMessages.generated.json +++ b/lib/tr/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Bir ad alanı bildirimi, birleştirildiği sınıf veya işlevden önce gelemez.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Ad alanı bildirimine yalnızca bir ad alanında veya modülde izin verilir.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Bir ad alanı stili içeri aktarma işlemi çağrılamadığından veya oluşturulamadığından çalışma zamanında hataya yol açacak.", - "A_non_dry_build_would_build_project_0_6357": "DRY dışı bir derleme '{0}' projesini derler", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "DRY dışı bir derleme şu dosyaları siler: {0}", + "A_non_dry_build_would_build_project_0_6357": "non-dry bir derleme '{0}' projesini derler", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "non-dry bir derleme şu dosyaları siler: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Parametre başlatıcısına yalnızca bir işlevde veya oluşturucu uygulamasında izin verilir.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Parametre özelliği, rest parametresi kullanılarak bildirilemez.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Parametre özelliğine yalnızca bir oluşturucu uygulamasında izin verilir.", diff --git a/lib/tsc.js b/lib/tsc.js index c4211aa1b3b..e3884ccf3bd 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -1,3 +1,19 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + + "use strict";"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -10,6 +26,33 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + 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; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; @@ -783,23 +826,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1587,8 +1613,9 @@ 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; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2559,6 +2586,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -2710,7 +2740,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -2830,6 +2859,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -2860,7 +2891,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -2930,6 +2961,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -2979,6 +3011,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -3126,6 +3159,9 @@ var ts; 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'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), 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."), @@ -3212,6 +3248,8 @@ var ts; 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}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), 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}'."), @@ -3511,6 +3549,10 @@ var ts; 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), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), 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}"), @@ -3542,6 +3584,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -3573,6 +3617,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -3717,6 +3762,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -5663,7 +5712,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274) { + while (node && node.kind !== 277) { node = node.parent; } return node; @@ -5671,11 +5720,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213: - case 241: - case 220: - case 221: - case 222: + case 216: + case 244: + case 223: + case 224: + case 225: return true; } return false; @@ -5768,7 +5817,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 300 && node._children.length > 0) { + if (node.kind === 303 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -5847,10 +5896,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; function makeIdentifierFromModuleName(moduleName) { return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } @@ -5862,7 +5907,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 && node.parent.kind === 269; + return node.kind === 235 && node.parent.kind === 272; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -5886,11 +5931,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 239 && (!node.body); + return node && node.kind === 242 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 || - node.kind === 239 || + return node.kind === 277 || + node.kind === 242 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5904,9 +5949,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 274: + case 277: return ts.isExternalModule(node.parent); - case 240: + case 243: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5918,22 +5963,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274: - case 241: - case 269: - case 239: - case 220: - case 221: - case 222: + case 277: + case 244: + case 272: + case 242: + case 223: + case 224: + case 225: case 155: case 154: case 156: case 157: - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: return true; - case 213: + case 216: return !ts.isFunctionLike(parentNode); } return false; @@ -5947,22 +5992,22 @@ var ts; case 160: case 163: case 164: - case 284: - case 235: - case 205: - case 236: + case 287: + case 238: + case 207: + case 239: + case 240: + case 300: case 237: - case 297: - case 234: case 154: case 155: case 156: case 157: - case 192: - case 193: - case 292: - case 298: - case 288: + case 194: + case 195: + case 295: + case 301: + case 291: return true; default: ts.assertTypeIsNever(node); @@ -5972,8 +6017,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244: - case 243: + case 247: + case 246: return true; default: return false; @@ -5982,15 +6027,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 244: - case 243: - case 214: - case 235: - case 234: - case 239: - case 237: - case 236: + case 247: + case 246: + case 217: case 238: + case 237: + case 242: + case 240: + case 239: + case 241: return true; default: return false; @@ -6006,7 +6051,7 @@ var ts; } ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -6033,7 +6078,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185: + case 187: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -6078,7 +6123,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213) { + if (node.body && node.body.kind === 216) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6090,31 +6135,31 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274: + case 277: 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 232: - case 182: case 235: - case 205: - case 236: - case 239: + case 184: case 238: - case 273: - case 234: - case 192: + case 207: + case 239: + case 242: + case 241: + case 276: + case 237: + case 194: case 154: case 156: case 157: - case 237: + case 240: case 152: case 151: errorNode = node.name; break; - case 193: + case 195: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6143,35 +6188,34 @@ var ts; return file.scriptKind === 6; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2) - || !!(ts.getCombinedModifierFlags(node) & 2048); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 && n.expression.kind === 97; + return n.kind === 189 && n.expression.kind === 97; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 && n.expression.kind === 91; + return n.kind === 189 && n.expression.kind === 91; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 && - n.argument.kind === 178 && + return n.kind === 181 && + n.argument.kind === 180 && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 + return node.kind === 219 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -6182,9 +6226,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 || node.kind === 148 || - node.kind === 192 || - node.kind === 193 || - node.kind === 191) ? + node.kind === 194 || + node.kind === 195 || + node.kind === 193) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -6199,7 +6243,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 <= node.kind && node.kind <= 179) { + if (161 <= node.kind && node.kind <= 181) { return true; } switch (node.kind) { @@ -6213,45 +6257,45 @@ var ts; case 131: return true; case 105: - return node.parent.kind !== 196; - case 207: + return node.parent.kind !== 198; + case 209: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148: - return node.parent.kind === 177 || node.parent.kind === 172; + return node.parent.kind === 179 || node.parent.kind === 174; case 71: if (node.parent.kind === 146 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 && node.parent.name === node) { + else if (node.parent.kind === 187 && node.parent.name === node) { node = node.parent; } - 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'."); + ts.Debug.assert(node.kind === 71 || node.kind === 146 || node.kind === 187, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); case 146: - case 185: + case 187: case 99: { var parent = node.parent; if (parent.kind === 165) { return false; } - if (parent.kind === 179) { + if (parent.kind === 181) { return !parent.isTypeOf; } - if (161 <= parent.kind && parent.kind <= 179) { + if (161 <= parent.kind && parent.kind <= 181) { return true; } switch (parent.kind) { - case 207: + case 209: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148: return node === parent.constraint; case 152: case 151: case 149: - case 232: + case 235: return node === parent.type; - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: case 155: case 154: case 153: @@ -6262,12 +6306,12 @@ var ts; case 159: case 160: return node === parent.type; - case 190: + case 192: return node === parent.type; - case 187: - case 188: - return ts.contains(parent.typeArguments, node); case 189: + case 190: + return ts.contains(parent.typeArguments, node); + case 191: return false; } } @@ -6289,23 +6333,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225: + case 228: return visitor(node); - case 241: - case 213: - case 217: - case 218: - case 219: + case 244: + case 216: case 220: case 221: case 222: - case 226: - case 227: - case 266: - case 267: - case 228: + case 223: + case 224: + case 225: + case 229: case 230: case 269: + case 270: + case 231: + case 233: + case 272: return ts.forEachChild(node, traverse); } } @@ -6315,19 +6359,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203: + case 205: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238: - case 236: + case 241: case 239: - case 237: - case 235: - case 205: + case 242: + case 240: + case 238: + case 207: return; default: if (ts.isFunctionLike(node)) { @@ -6357,12 +6401,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236: - case 235: - case 205: + case 239: + case 238: + case 207: case 166: return node.members; - case 184: + case 186: return node.properties; } } @@ -6370,14 +6414,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182: - case 273: + case 184: + case 276: case 149: - case 270: + case 273: case 152: case 151: - case 271: - case 232: + case 274: + case 235: return true; } } @@ -6389,12 +6433,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 - && node.parent.parent.kind === 214; + return node.parent.kind === 236 + && node.parent.parent.kind === 217; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -6406,8 +6450,8 @@ var ts; case 155: case 156: case 157: - case 234: - case 192: + case 237: + case 194: return true; } return false; @@ -6418,7 +6462,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228) { + if (node.statement.kind !== 231) { return node.statement; } node = node.statement; @@ -6426,17 +6470,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 && ts.isFunctionLike(node.parent); + return node && node.kind === 216 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 && node.parent.kind === 184; + return node && node.kind === 154 && node.parent.kind === 186; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 && - (node.parent.kind === 184 || - node.parent.kind === 205); + (node.parent.kind === 186 || + node.parent.kind === 207); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6449,7 +6493,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270) { + if (property.kind === 273) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -6486,7 +6530,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274); + ts.Debug.assert(node.kind !== 277); while (true) { node = node.parent; if (!node) { @@ -6507,13 +6551,13 @@ var ts; node = node.parent; } break; - case 193: + case 195: if (!includeArrowFunctions) { continue; } - case 234: - case 192: - case 239: + case 237: + case 194: + case 242: case 152: case 151: case 154: @@ -6524,8 +6568,8 @@ var ts; case 158: case 159: case 160: - case 238: - case 274: + case 241: + case 277: return node; } } @@ -6536,8 +6580,8 @@ var ts; if (container) { switch (container.kind) { case 155: - case 234: - case 192: + case 237: + case 194: return container; } } @@ -6554,9 +6598,9 @@ var ts; case 147: node = node.parent; break; - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: if (!stopOnFunctions) { continue; } @@ -6581,14 +6625,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 || func.kind === 193) { + if (func.kind === 194 || func.kind === 195) { var prev = func; var parent = func.parent; - while (parent.kind === 191) { + while (parent.kind === 193) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 && parent.expression === prev) { + if (parent.kind === 189 && parent.expression === prev) { return parent; } } @@ -6596,13 +6640,13 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 || kind === 186) + return (kind === 187 || kind === 188) && node.expression.kind === 97; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 185 || kind === 186) + return (kind === 187 || kind === 188) && node.expression.kind === 99; } ts.isThisProperty = isThisProperty; @@ -6610,7 +6654,7 @@ var ts; switch (node.kind) { case 162: return node.typeName; - case 207: + case 209: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -6623,10 +6667,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189: + case 191: return node.tag; - case 257: - case 256: + case 260: + case 259: return node.tagName; default: return node.expression; @@ -6635,21 +6679,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235: + case 238: return true; case 152: - return parent.kind === 235; + return parent.kind === 238; case 156: case 157: case 154: return node.body !== undefined - && parent.kind === 235; + && parent.kind === 238; case 149: return parent.body !== undefined && (parent.kind === 155 || parent.kind === 154 || parent.kind === 157) - && grandparent.kind === 235; + && grandparent.kind === 238; } return false; } @@ -6665,7 +6709,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235: + case 238: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); case 154: case 157: @@ -6677,9 +6721,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 || - parent.kind === 256 || - parent.kind === 258) { + if (parent.kind === 260 || + parent.kind === 259 || + parent.kind === 261) { return parent.tagName === node; } return false; @@ -6692,37 +6736,37 @@ var ts; case 101: case 86: case 12: - case 183: - case 184: case 185: case 186: case 187: case 188: case 189: - case 208: case 190: - case 209: case 191: + case 210: case 192: - case 205: + case 211: case 193: - case 196: case 194: + case 207: case 195: case 198: - case 199: + case 196: + case 197: case 200: case 201: - case 204: case 202: - case 13: - case 206: - case 255: - case 256: - case 259: case 203: - case 197: - case 210: + case 206: + case 204: + case 13: + case 208: + case 258: + case 259: + case 262: + case 205: + case 199: + case 212: return true; case 146: while (node.parent.kind === 146) { @@ -6745,47 +6789,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232: + case 235: case 149: case 152: case 151: + case 276: case 273: - case 270: - case 182: + case 184: return parent.initializer === node; - case 216: - case 217: - case 218: case 219: - case 225: - case 226: - case 227: - case 266: - case 229: - return parent.expression === node; case 220: - var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233) || - forStatement.condition === node || - forStatement.incrementor === node; case 221: case 222: + case 228: + case 229: + case 230: + case 269: + case 232: + return parent.expression === node; + case 223: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 236) || + forStatement.condition === node || + forStatement.incrementor === node; + case 224: + case 225: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236) || forInStatement.expression === node; - case 190: - case 208: + case 192: + case 210: return node === parent.expression; - case 211: + case 214: return node === parent.expression; case 147: return node === parent.expression; case 150: - case 265: - case 264: - case 272: + case 268: + case 267: + case 275: return true; - case 207: + case 209: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -6793,7 +6837,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 && node.moduleReference.kind === 254; + return node.kind === 246 && node.moduleReference.kind === 257; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -6802,7 +6846,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 && node.moduleReference.kind !== 254; + return node.kind === 246 && node.moduleReference.kind !== 257; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -6834,7 +6878,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187) { + if (callExpression.kind !== 189) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -6914,11 +6958,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 || e.kind === 193 ? initializer : undefined; + return e.kind === 194 || e.kind === 195 ? initializer : undefined; } - if (initializer.kind === 192 || - initializer.kind === 205 || - initializer.kind === 193) { + if (initializer.kind === 194 || + initializer.kind === 207 || + initializer.kind === 195) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -6990,6 +7034,13 @@ var ts; return 0; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + return 6; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99) { return 4; } @@ -6997,10 +7048,7 @@ var ts; return 2; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - return 6; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { return 3; } var nextToLast = lhs; @@ -7017,7 +7065,7 @@ var ts; } return 0; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -7031,7 +7079,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 && + expr.parent && expr.parent.kind === 219 && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -7041,14 +7089,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244: - case 250: + case 247: + case 253: return node.parent; - case 254: + case 257: return node.parent.parent; - case 187: + case 189: return node.parent; - case 178: + case 180: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -7058,12 +7106,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244: - case 250: + case 247: + case 253: return node.moduleSpecifier; - case 243: - return node.moduleReference.kind === 254 ? node.moduleReference.expression : undefined; - case 179: + case 246: + return node.moduleReference.kind === 257 ? node.moduleReference.expression : undefined; + case 181: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -7072,11 +7120,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244: + case 247: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243: + case 246: return node; - case 250: + case 253: return undefined; default: return ts.Debug.assertNever(node); @@ -7084,7 +7132,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 && !!node.importClause && !!node.importClause.name; + return node.kind === 247 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -7093,8 +7141,8 @@ var ts; case 149: case 154: case 153: - case 271: - case 270: + case 274: + case 273: case 152: case 151: return node.questionToken !== undefined; @@ -7104,14 +7152,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 && + return node.kind === 287 && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 || node.kind === 292; + return node.kind === 301 || node.kind === 295; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -7136,12 +7184,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214: + case 217: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152: return node.initializer; - case 270: + case 273: return node.initializer; } } @@ -7151,52 +7199,50 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 + node.body.kind === 242 ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - if (parent.kind === 270 || parent.kind === 152 || getNestedModuleDeclaration(parent)) { - getJSDocCommentsAndTagsWorker(parent); - } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 || - node.kind === 185 && node.parent && node.parent.kind === 216) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } - } - if (node.kind === 149) { - result = ts.addRange(result, ts.getJSDocParameterTags(node)); - } - if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { - result = ts.addRange(result, node.initializer.jsDoc); - } + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } + if (node.kind === 149) { + result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; + } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 || + parent.kind === 152 || + parent.kind === 219 && node.kind === 187 || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58) { + return parent; + } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } function getParameterSymbolFromJSDoc(node) { if (node.symbol) { return node.symbol; @@ -7244,38 +7290,38 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 200: + case 202: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 ? 1 : 2 : 0; - case 198: - case 199: + case 200: + case 201: var unaryOperator = parent.operator; return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; - case 221: - case 222: + case 224: + case 225: return parent.initializer === node ? 1 : 0; - case 191: - case 183: - case 204: - case 209: + case 193: + case 185: + case 206: + case 211: node = parent; break; - case 271: + case 274: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 270: + case 273: if (parent.name === node) { return 0; } @@ -7294,22 +7340,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 213: - case 214: - case 226: + case 216: case 217: - case 227: - case 241: - case 266: - case 267: - case 228: + case 229: case 220: + case 230: + case 244: + case 269: + case 270: + case 231: + case 223: + case 224: + case 225: case 221: case 222: - case 218: - case 219: - case 230: - case 269: + case 233: + case 272: return true; } return false; @@ -7326,26 +7372,26 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173); + return walkUp(node, 175); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191); + return walkUp(node, 193); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191) { + while (node.kind === 193) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function isDeleteTarget(node) { - if (node.kind !== 185 && node.kind !== 186) { + if (node.kind !== 187 && node.kind !== 188) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194; + return node && node.kind === 196; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -7399,9 +7445,9 @@ var ts; case 153: case 156: case 157: + case 276: case 273: - case 270: - case 185: + case 187: return parent.name === node; case 146: if (parent.right === node) { @@ -7411,24 +7457,24 @@ var ts; return parent.kind === 165 || parent.kind === 162; } return false; - case 182: - case 248: + case 184: + case 251: return parent.propertyName === node; - case 252: - case 262: + case 255: + case 265: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(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) || + return node.kind === 246 || + node.kind === 245 || + node.kind === 248 && !!node.name || + node.kind === 249 || + node.kind === 251 || + node.kind === 255 || + node.kind === 252 && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -7437,11 +7483,21 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108); return heritageClause ? heritageClause.types : undefined; @@ -7449,7 +7505,7 @@ var ts; ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -7514,13 +7570,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 234: - case 192: + case 237: + case 194: case 154: if (node.asteriskToken) { flags |= 1; } - case 193: + case 195: if (hasModifier(node, 256)) { flags |= 2; } @@ -7534,9 +7590,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: case 154: return node.body !== undefined && node.asteriskToken === undefined @@ -7627,7 +7683,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182) { + while (node.kind === 184) { node = node.parent.parent; } return node; @@ -7636,14 +7692,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 - || kind === 192 - || kind === 234 - || kind === 193 + || kind === 194 + || kind === 237 + || kind === 195 || kind === 154 || kind === 156 || kind === 157 - || kind === 239 - || kind === 274; + || kind === 242 + || kind === 277; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -7657,23 +7713,23 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188: + case 190: return hasArguments ? 0 : 1; - case 198: - case 195: - case 196: - case 194: - case 197: - case 201: - case 203: - return 1; case 200: + case 197: + case 198: + case 196: + case 199: + case 203: + case 205: + return 1; + case 202: switch (operator) { case 40: case 58: @@ -7697,15 +7753,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200) { + if (expression.kind === 202) { return expression.operatorToken.kind; } - else if (expression.kind === 198 || expression.kind === 199) { + else if (expression.kind === 200 || expression.kind === 201) { return expression.operator; } else { @@ -7715,15 +7771,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303: + case 306: return 0; - case 204: + case 206: return 1; - case 203: + case 205: return 2; - case 201: + case 203: return 4; - case 200: + case 202: switch (operatorKind) { case 26: return 0; @@ -7744,21 +7800,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198: - case 195: - case 196: - case 194: + case 200: case 197: - return 16; + case 198: + case 196: case 199: + return 16; + case 201: return 17; - case 187: - return 18; - case 188: - return hasArguments ? 19 : 18; case 189: - case 185: - case 186: + return 18; + case 190: + return hasArguments ? 19 : 18; + case 191: + case 187: + case 188: return 19; case 99: case 97: @@ -7768,19 +7824,19 @@ var ts; case 86: case 8: case 9: - case 183: - case 184: - case 192: - case 193: - case 205: - case 255: - case 256: + case 185: + case 186: + case 194: + case 195: + case 207: + case 258: case 259: + case 262: case 12: case 13: - case 202: - case 191: - case 206: + case 204: + case 193: + case 208: return 20; default: return -1; @@ -7836,6 +7892,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -7843,6 +7900,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -8221,7 +8295,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286); + ts.Debug.assert(node.parent.kind === 289); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); @@ -8232,7 +8306,7 @@ var ts; } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 && tag.parent.tags.some(isJSDocTypeAlias)); } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); @@ -8476,8 +8550,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 184 - || kind === 183; + return kind === 186 + || kind === 185; } return false; } @@ -8487,7 +8561,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 + return node.kind === 209 && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 @@ -8509,16 +8583,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 && node.parent.right === node) || - (node.parent.kind === 185 && node.parent.name === node); + (node.parent.kind === 187 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 && + return expression.kind === 186 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 && + return expression.kind === 185 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -8798,8 +8872,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238: - case 239: + case 241: + case 242: return parseNode === parseNode.parent.name; } } @@ -8865,20 +8939,20 @@ var ts; if (!parent) return 0; switch (parent.kind) { - case 199: - case 198: + case 201: + case 200: var operator = parent.operator; return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; - case 200: + case 202: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; - case 185: + case 187: return parent.name !== node ? 0 : accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && parent.parent.kind === 216 ? 1 : 2; + return parent.parent && parent.parent.kind === 219 ? 1 : 2; } } function compareDataObjects(dst, src) { @@ -8967,7 +9041,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -9036,6 +9110,10 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); } @@ -9138,7 +9216,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239) { return current; } } @@ -9163,42 +9241,37 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235) { node = node.parent; } - if (node && node.kind === 233) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232) { - node = node.parent; - } - if (node && node.kind === 233) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; function validateLocaleAndSetLanguage(locale, sys, errors) { @@ -9286,10 +9359,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; function nameForNamelessJSDocTypedef(declaration) { var hostNode = declaration.parent.parent; if (!hostNode) { @@ -9299,17 +9368,17 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 214: + case 217: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216: + case 219: var expr = hostNode.expression; switch (expr.kind) { - case 185: + case 187: return expr.name; - case 186: + case 188: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -9318,10 +9387,10 @@ var ts; return undefined; case 1: return undefined; - case 191: { + case 193: { return getDeclarationIdentifier(hostNode.expression); } - case 228: { + case 231: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -9333,7 +9402,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -9343,28 +9412,19 @@ var ts; return !!node.name; } ts.isNamedDeclaration = isNamedDeclaration; - function getNameOfDeclaration(declaration) { - if (!declaration) { - return undefined; - } + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205: - case 192: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71: return declaration; - case 299: - case 293: { + case 302: + case 296: { var name = declaration.name; if (name.kind === 146) { return name.right; } break; } - case 200: { + case 202: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1: @@ -9376,17 +9436,22 @@ var ts; return undefined; } } - case 292: - return declaration.name; - case 298: + case 301: return getNameOfJSDocTypedef(declaration); - case 249: { + case 252: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -9619,540 +9684,540 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169; + return node.kind === 171; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170; + return node.kind === 172; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171; + return node.kind === 173; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172; + return node.kind === 174; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173; + return node.kind === 175; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174; + return node.kind === 176; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175; + return node.kind === 177; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176; + return node.kind === 178; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177; + return node.kind === 179; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178; + return node.kind === 180; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179; + return node.kind === 181; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 180; + return node.kind === 182; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181; + return node.kind === 183; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182; + return node.kind === 184; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 183; + return node.kind === 185; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184; + return node.kind === 186; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185; + return node.kind === 187; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186; + return node.kind === 188; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187; + return node.kind === 189; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188; + return node.kind === 190; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189; + return node.kind === 191; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190; + return node.kind === 192; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191; + return node.kind === 193; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302) { + while (node.kind === 305) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192; + return node.kind === 194; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193; + return node.kind === 195; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194; + return node.kind === 196; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195; + return node.kind === 197; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196; + return node.kind === 198; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197; + return node.kind === 199; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198; + return node.kind === 200; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199; + return node.kind === 201; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200; + return node.kind === 202; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201; + return node.kind === 203; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202; + return node.kind === 204; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203; + return node.kind === 205; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204; + return node.kind === 206; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205; + return node.kind === 207; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206; + return node.kind === 208; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207; + return node.kind === 209; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208; + return node.kind === 210; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209; + return node.kind === 211; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210; + return node.kind === 212; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 211; + return node.kind === 214; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212; + return node.kind === 215; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 213; + return node.kind === 216; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214; + return node.kind === 217; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215; + return node.kind === 218; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216; + return node.kind === 219; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217; + return node.kind === 220; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218; + return node.kind === 221; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219; + return node.kind === 222; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220; + return node.kind === 223; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221; + return node.kind === 224; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222; + return node.kind === 225; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223; + return node.kind === 226; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224; + return node.kind === 227; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 || node.kind === 223; + return node.kind === 227 || node.kind === 226; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225; + return node.kind === 228; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226; + return node.kind === 229; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227; + return node.kind === 230; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228; + return node.kind === 231; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229; + return node.kind === 232; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230; + return node.kind === 233; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231; + return node.kind === 234; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232; + return node.kind === 235; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233; + return node.kind === 236; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234; + return node.kind === 237; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235; + return node.kind === 238; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236; + return node.kind === 239; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237; + return node.kind === 240; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238; + return node.kind === 241; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239; + return node.kind === 242; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240; + return node.kind === 243; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241; + return node.kind === 244; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242; + return node.kind === 245; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243; + return node.kind === 246; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244; + return node.kind === 247; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245; + return node.kind === 248; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246; + return node.kind === 249; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247; + return node.kind === 250; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248; + return node.kind === 251; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249; + return node.kind === 252; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250; + return node.kind === 253; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251; + return node.kind === 254; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252; + return node.kind === 255; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253; + return node.kind === 256; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 254; + return node.kind === 257; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 255; + return node.kind === 258; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256; + return node.kind === 259; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257; + return node.kind === 260; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258; + return node.kind === 261; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259; + return node.kind === 262; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260; + return node.kind === 263; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261; + return node.kind === 264; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262; + return node.kind === 265; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263; + return node.kind === 266; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264; + return node.kind === 267; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265; + return node.kind === 268; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 266; + return node.kind === 269; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267; + return node.kind === 270; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268; + return node.kind === 271; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269; + return node.kind === 272; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 270; + return node.kind === 273; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271; + return node.kind === 274; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272; + return node.kind === 275; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 273; + return node.kind === 276; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 274; + return node.kind === 277; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275; + return node.kind === 278; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276; + return node.kind === 279; } ts.isUnparsedSource = isUnparsedSource; function isJSDocTypeExpression(node) { - return node.kind === 278; + return node.kind === 281; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279; + return node.kind === 282; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280; + return node.kind === 283; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281; + return node.kind === 284; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282; + return node.kind === 285; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283; + return node.kind === 286; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284; + return node.kind === 287; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285; + return node.kind === 288; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286; + return node.kind === 289; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290; + return node.kind === 293; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291; + return node.kind === 294; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295; + return node.kind === 298; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293; + return node.kind === 296; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294; + return node.kind === 297; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296; + return node.kind === 299; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297; + return node.kind === 300; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298; + return node.kind === 301; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299; + return node.kind === 302; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 || node.kind === 293; + return node.kind === 302 || node.kind === 296; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287; + return node.kind === 290; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292; + return node.kind === 295; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288; + return node.kind === 291; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 300; + return n.kind === 303; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -10248,8 +10313,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 - || kind === 180 - || kind === 181; + || kind === 182 + || kind === 183; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -10262,13 +10327,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234: + case 237: case 154: case 155: case 156: case 157: - case 192: - case 193: + case 194: + case 195: return true; default: return false; @@ -10278,11 +10343,11 @@ var ts; switch (kind) { case 153: case 158: - case 288: + case 291: case 159: case 160: case 163: - case 284: + case 287: case 164: return true; default: @@ -10302,11 +10367,11 @@ var ts; || kind === 156 || kind === 157 || kind === 160 - || kind === 212; + || kind === 215; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 || node.kind === 205); + return node && (node.kind === 238 || node.kind === 207); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -10339,16 +10404,16 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 - || kind === 271 - || kind === 272 + return kind === 273 + || kind === 274 + || kind === 275 || kind === 154 || kind === 156 || kind === 157; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 161 && kind <= 179) + return (kind >= 161 && kind <= 181) || kind === 119 || kind === 142 || kind === 134 @@ -10361,14 +10426,14 @@ var ts; || kind === 140 || kind === 95 || kind === 131 - || kind === 207 - || kind === 279 - || kind === 280 - || kind === 281 + || kind === 209 || kind === 282 || kind === 283 || kind === 284 - || kind === 285; + || kind === 285 + || kind === 286 + || kind === 287 + || kind === 288; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -10386,29 +10451,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 - || kind === 180; + return kind === 183 + || kind === 182; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 - || kind === 184; + return kind === 185 + || kind === 186; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 - || kind === 206; + return kind === 184 + || kind === 208; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232: + case 235: case 149: - case 182: + case 184: return true; } return false; @@ -10421,8 +10486,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180: - case 184: + case 182: + case 186: return true; } return false; @@ -10430,8 +10495,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181: case 183: + case 185: return true; } return false; @@ -10439,24 +10504,24 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 + return kind === 187 || kind === 146 - || kind === 179; + || kind === 181; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 + return kind === 187 || kind === 146; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257: - case 256: - case 187: - case 188: + case 260: + case 259: case 189: + case 190: + case 191: case 150: return true; default: @@ -10465,12 +10530,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 || node.kind === 188; + return node.kind === 189 || node.kind === 190; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 + return kind === 204 || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; @@ -10480,32 +10545,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 185: - case 186: - case 188: case 187: - case 255: - case 256: - case 259: + case 188: + case 190: case 189: - case 183: + case 258: + case 259: + case 262: case 191: - case 184: - case 205: - case 192: + case 185: + case 193: + case 186: + case 207: + case 194: case 71: case 12: case 8: case 9: case 13: - case 202: + case 204: case 86: case 95: case 99: case 101: case 97: - case 209: - case 210: + case 211: + case 212: case 91: return true; default: @@ -10518,13 +10583,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198: - case 199: - case 194: - case 195: + case 200: + case 201: case 196: case 197: - case 190: + case 198: + case 199: + case 192: return true; default: return isLeftHandSideExpressionKind(kind); @@ -10532,9 +10597,9 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199: + case 201: return true; - case 198: + case 200: return expr.operator === 43 || expr.operator === 44; default: @@ -10548,15 +10613,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201: case 203: - case 193: - case 200: - case 204: - case 208: + case 205: + case 195: + case 202: case 206: - case 303: - case 302: + case 210: + case 208: + case 306: + case 305: return true; default: return isUnaryExpressionKind(kind); @@ -10564,16 +10629,16 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 - || kind === 208; + return kind === 192 + || kind === 210; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 302; + return node.kind === 305; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 301; + return node.kind === 304; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10583,20 +10648,20 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220: + case 223: + case 224: + case 225: case 221: case 222: - case 218: - case 219: return true; - case 228: + case 231: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isForInOrOfStatement(node) { - return node.kind === 221 || node.kind === 222; + return node.kind === 224 || node.kind === 225; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -10615,108 +10680,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 240 - || kind === 239 + return kind === 243 + || kind === 242 || kind === 71; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 - || kind === 239; + return kind === 243 + || kind === 242; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 - || kind === 239; + || kind === 242; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 - || kind === 246; + return kind === 250 + || kind === 249; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 239 || node.kind === 238; + return node.kind === 242 || node.kind === 241; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 - || kind === 182 - || kind === 235 - || kind === 205 - || kind === 155 + return kind === 195 + || kind === 184 || kind === 238 - || kind === 273 - || kind === 252 - || kind === 234 - || kind === 192 + || kind === 207 + || kind === 155 + || kind === 241 + || kind === 276 + || kind === 255 + || kind === 237 + || kind === 194 || kind === 156 - || kind === 245 - || kind === 243 || kind === 248 - || kind === 236 - || kind === 262 + || kind === 246 + || kind === 251 + || kind === 239 + || kind === 265 || kind === 154 || kind === 153 - || kind === 239 || kind === 242 - || kind === 246 + || kind === 245 + || kind === 249 || kind === 149 - || kind === 270 + || kind === 273 || kind === 152 || kind === 151 || kind === 157 - || kind === 271 - || kind === 237 + || kind === 274 + || kind === 240 || kind === 148 - || kind === 232 - || kind === 298 - || kind === 292 - || kind === 299; + || kind === 235 + || kind === 301 + || kind === 295 + || kind === 302; } function isDeclarationStatementKind(kind) { - return kind === 234 - || kind === 253 - || kind === 235 - || kind === 236 - || kind === 237 + return kind === 237 + || kind === 256 || kind === 238 || kind === 239 - || kind === 244 - || kind === 243 - || kind === 250 - || kind === 249 - || kind === 242; + || kind === 240 + || kind === 241 + || kind === 242 + || kind === 247 + || kind === 246 + || kind === 253 + || kind === 252 + || kind === 245; } function isStatementKindButNotDeclarationKind(kind) { - 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 === 227 - || kind === 229 - || kind === 230 - || kind === 214 - || kind === 219 + return kind === 227 || kind === 226 - || kind === 301 - || kind === 305 - || kind === 304; + || kind === 234 + || kind === 221 + || kind === 219 + || kind === 218 + || kind === 224 + || kind === 225 + || kind === 223 + || kind === 220 + || kind === 231 + || kind === 228 + || kind === 230 + || kind === 232 + || kind === 233 + || kind === 217 + || kind === 222 + || kind === 229 + || kind === 304 + || kind === 308 + || kind === 307; } function isDeclaration(node) { if (node.kind === 148) { - return node.parent.kind !== 297 || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -10737,10 +10802,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213) + if (node.kind !== 216) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 || node.parent.kind === 269) { + if (node.parent.kind === 233 || node.parent.kind === 272) { return false; } } @@ -10748,7 +10813,7 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 254 + return kind === 257 || kind === 146 || kind === 71; } @@ -10757,52 +10822,52 @@ var ts; var kind = node.kind; return kind === 99 || kind === 71 - || kind === 185; + || kind === 187; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 255 - || kind === 265 - || kind === 256 + return kind === 258 + || kind === 268 + || kind === 259 || kind === 10 - || kind === 259; + || kind === 262; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 - || kind === 264; + return kind === 265 + || kind === 267; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 265; + || kind === 268; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 - || kind === 256; + return kind === 260 + || kind === 259; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 - || kind === 267; + return kind === 269 + || kind === 270; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 278 && node.kind <= 299; + return node.kind >= 281 && node.kind <= 302; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 286 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 289 && node.kind <= 299; + return node.kind >= 292 && node.kind <= 302; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -10838,22 +10903,22 @@ var ts; case 161: case 163: case 164: - case 173: case 175: case 177: - case 190: + case 179: case 192: - case 193: - case 208: - case 232: - case 234: + case 194: + case 195: + case 210: + case 235: case 237: - case 278: + case 240: case 281: - case 282: - case 283: case 284: case 285: + case 286: + case 287: + case 288: return true; } return false; @@ -10869,10 +10934,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262: - case 264: - case 270: - case 271: + case 265: + case 267: + case 273: + case 274: case 154: case 156: case 157: @@ -10883,7 +10948,7 @@ var ts; } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 162 || node.kind === 207; + return node.kind === 162 || node.kind === 209; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -10917,7 +10982,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 247 || node.kind === 251; + return node.kind === 250 || node.kind === 254; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -11054,6 +11119,12 @@ var ts; return diagnostic.file ? diagnostic.file.path : undefined; } function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0; + } + ts.compareDiagnostics = compareDiagnostics; + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -11061,7 +11132,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); + }) || 0; + } + return d1.relatedInformation ? -1 : 1; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -11497,17 +11580,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.tryRemovePrefix(path, dirPath); - if (a === undefined) - return undefined; - switch (a.charCodeAt(0)) { - case 47: - case 92: - return a.slice(1); - default: - return undefined; - } + function isDirectorySeparator(charCode) { + return charCode === 47 || charCode === 92; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; var reservedCharacterPattern = /[^\w\s\/]/g; @@ -11954,7 +12035,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 274) { + if (kind === 277) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71) { @@ -12004,14 +12085,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271: + case 274: 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 272: + case 275: return visitNode(cbNode, node.expression); case 149: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -12036,20 +12117,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270: + case 273: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 232: + case 235: 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 182: + case 184: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -12071,9 +12152,9 @@ var ts; case 155: case 156: case 157: - case 192: - case 234: - case 193: + case 194: + case 237: + case 195: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12098,290 +12179,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169: - case 170: - return visitNodes(cbNode, cbNodes, node.types); case 171: + case 172: + return visitNodes(cbNode, cbNodes, node.types); + case 173: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172: + case 174: return visitNode(cbNode, node.typeParameter); - case 179: + case 181: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173: case 175: + case 177: return visitNode(cbNode, node.type); - case 176: + case 178: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177: + case 179: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178: - return visitNode(cbNode, node.literal); case 180: - case 181: - return visitNodes(cbNode, cbNodes, node.elements); + return visitNode(cbNode, node.literal); + case 182: case 183: return visitNodes(cbNode, cbNodes, node.elements); - case 184: - return visitNodes(cbNode, cbNodes, node.properties); case 185: + return visitNodes(cbNode, cbNodes, node.elements); + case 186: + return visitNodes(cbNode, cbNodes, node.properties); + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187: - case 188: + case 189: + case 190: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189: + case 191: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190: + case 192: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191: - return visitNode(cbNode, node.expression); - case 194: - return visitNode(cbNode, node.expression); - case 195: + case 193: return 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 198: + return visitNode(cbNode, node.expression); case 200: + return visitNode(cbNode, node.operand); + case 205: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 199: + return visitNode(cbNode, node.expression); + case 201: + return visitNode(cbNode, node.operand); + case 202: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208: + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209: + case 211: return visitNode(cbNode, node.expression); - case 210: + case 212: return visitNode(cbNode, node.name); - case 201: + case 203: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204: + case 206: return visitNode(cbNode, node.expression); - case 213: - case 240: + case 216: + case 243: return visitNodes(cbNode, cbNodes, node.statements); - case 274: + case 277: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214: + case 217: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233: + case 236: return visitNodes(cbNode, cbNodes, node.declarations); - case 216: + case 219: return visitNode(cbNode, node.expression); - case 217: + case 220: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218: + case 221: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219: + case 222: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220: + case 223: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221: + case 224: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222: + case 225: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223: - case 224: - return visitNode(cbNode, node.label); - case 225: - return visitNode(cbNode, node.expression); case 226: + case 227: + return visitNode(cbNode, node.label); + case 228: + return visitNode(cbNode, node.expression); + case 229: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227: + case 230: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241: + case 244: return visitNodes(cbNode, cbNodes, node.clauses); - case 266: + case 269: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267: + case 270: return visitNodes(cbNode, cbNodes, node.statements); - case 228: + case 231: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229: + case 232: return visitNode(cbNode, node.expression); - case 230: + case 233: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269: + case 272: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150: return visitNode(cbNode, node.expression); - case 235: - case 205: - 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: - 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 237: - 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 238: + case 207: 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 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) || + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNodes(cbNode, cbNodes, node.heritageClauses) || + visitNodes(cbNode, cbNodes, node.members); + case 240: + 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 241: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.members); + case 276: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 242: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243: + case 246: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244: + case 247: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245: + case 248: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242: + case 245: return visitNode(cbNode, node.name); - case 246: + case 249: return visitNode(cbNode, node.name); - case 247: - case 251: - return visitNodes(cbNode, cbNodes, node.elements); case 250: + case 254: + return visitNodes(cbNode, cbNodes, node.elements); + case 253: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248: - case 252: + case 251: + case 255: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249: + case 252: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202: + case 204: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211: + case 214: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147: return visitNode(cbNode, node.expression); - case 268: + case 271: return visitNodes(cbNode, cbNodes, node.types); - case 207: + case 209: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254: + case 257: return visitNode(cbNode, node.expression); - case 253: + case 256: return visitNodes(cbNode, cbNodes, node.decorators); - case 303: + case 306: return visitNodes(cbNode, cbNodes, node.elements); - case 255: + case 258: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259: + case 262: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256: - case 257: + case 259: + case 260: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263: + case 266: return visitNodes(cbNode, cbNodes, node.properties); - case 262: + case 265: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264: + case 267: return visitNode(cbNode, node.expression); - case 265: + case 268: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258: + case 261: return visitNode(cbNode, node.tagName); - case 278: - return visitNode(cbNode, node.type); - case 282: - return visitNode(cbNode, node.type); + case 169: + case 170: case 281: - return visitNode(cbNode, node.type); - case 283: - return visitNode(cbNode, node.type); + case 285: case 284: + case 286: + case 288: + return visitNode(cbNode, node.type); + case 287: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285: - return visitNode(cbNode, node.type); - case 286: + case 289: return visitNodes(cbNode, cbNodes, node.tags); - case 293: - case 299: + case 296: + case 302: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -12390,17 +12469,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294: - return visitNode(cbNode, node.typeExpression); - case 296: - return visitNode(cbNode, node.typeExpression); - case 290: - return visitNode(cbNode, node.class); case 297: + return visitNode(cbNode, node.typeExpression); + case 299: + return visitNode(cbNode, node.typeExpression); + case 293: + return visitNode(cbNode, node.class); + case 300: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298: + case 301: if (node.typeExpression && - node.typeExpression.kind === 278) { + node.typeExpression.kind === 281) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -12408,18 +12487,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292: + case 295: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295: + case 298: return visitNode(cbNode, node.typeExpression); - case 288: + case 291: 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 287: + case 290: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -12427,7 +12506,7 @@ var ts; } } return; - case 302: + case 305: return visitNode(cbNode, node.expression); } } @@ -12534,7 +12613,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216); + var statement = createNode(219); switch (token()) { case 21: statement.expression = parseArrayLiteralExpression(); @@ -12644,13 +12723,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -12677,7 +12753,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(274, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(277, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13310,7 +13386,7 @@ var ts; case 156: case 157: case 152: - case 212: + case 215: return true; case 154: var methodDeclaration = node; @@ -13324,8 +13400,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266: - case 267: + case 269: + case 270: return true; } } @@ -13334,42 +13410,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 234: - case 214: - case 213: + case 237: case 217: case 216: - case 229: - case 225: - case 227: - case 224: - case 223: - case 221: - case 222: case 220: case 219: - case 226: - case 215: - case 230: + case 232: case 228: + case 230: + case 227: + case 226: + case 224: + case 225: + case 223: + case 222: + case 229: case 218: + case 233: case 231: - case 244: - case 243: - case 250: - case 249: - case 239: - case 235: - case 236: + case 221: + case 234: + case 247: + case 246: + case 253: + case 252: + case 242: case 238: - case 237: + case 239: + case 241: + case 240: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273; + return node.kind === 276; } function isReusableTypeMember(node) { if (node) { @@ -13385,7 +13461,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232) { + if (node.kind !== 235) { return false; } var variableDeclarator = node; @@ -13476,7 +13552,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -13515,7 +13596,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202); + var template = createNode(204); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); var list = []; @@ -13527,7 +13608,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211); + var span = createNode(214); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18) { @@ -13585,9 +13666,9 @@ var ts; case 163: case 164: { var _a = node, parameters = _a.parameters, type = _a.type; - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173: + case 175: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -13601,14 +13682,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174); + var node = createNode(176); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279); + var result = createNode(282); if (postFixEquals) { - return createJSDocPostfixType(283, result); + return createPostfixType(286, result); } else { nextToken(); @@ -13616,7 +13697,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282); + var result = createNode(285); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -13630,18 +13711,18 @@ var ts; token() === 29 || token() === 58 || token() === 49) { - var result = createNode(280, pos); + var result = createNode(283, pos); return finishNode(result); } else { - var result = createNode(281, pos); + var result = createNode(284, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284); + var result = createNodeWithJSDoc(287); nextToken(); fillSignature(56, 4 | 32, result); return finishNode(result); @@ -13663,12 +13744,12 @@ var ts; var dotdotdot = parseOptionalToken(24); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285, dotdotdot.pos); + var variadic = createNode(288, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58) { - return createJSDocPostfixType(283, type); + return createPostfixType(286, type); } return type; } @@ -13930,7 +14011,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177); + var node = createNode(179); parseExpected(17); if (token() === 132 || token() === 37 || token() === 38) { node.readonlyToken = parseTokenNode(); @@ -13952,13 +14033,26 @@ var ts; parseExpected(18); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24)) { + var node = createNode(170, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152) && type.kind === 284 && type.pos === type.type.pos) { + type.kind = 169; + } + return type; + } function parseTupleType() { var node = createNode(168); - node.elementTypes = parseBracketedList(20, parseType, 21, 22); + node.elementTypes = parseBracketedList(20, parseTupleElementType, 21, 22); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173); + var node = createNode(175); parseExpected(19); node.type = parseType(); parseExpected(20); @@ -13976,10 +14070,10 @@ var ts; return token() === 23 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178); + var node = createNode(180); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198); + unaryMinusExpression = createNode(200); unaryMinusExpression.operator = 38; nextToken(); } @@ -14000,7 +14094,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288; - var node = createNode(179); + var node = createNode(181); if (parseOptional(103)) { node.isTypeOf = true; } @@ -14123,18 +14217,18 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51: - type = createJSDocPostfixType(282, type); + type = createPostfixType(285, type); break; case 55: if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(281, type); + type = createPostfixType(284, type); break; case 21: parseExpected(21); if (isStartOfType()) { - var node = createNode(176, type.pos); + var node = createNode(178, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22); @@ -14153,21 +14247,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175); + var node = createNode(177); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172); + var node = createNode(174); parseExpected(126); var typeParameter = createNode(148); typeParameter.name = parseIdentifier(); @@ -14200,10 +14294,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170, parseTypeOperatorOrHigher, 48); + return parseUnionOrIntersectionType(172, parseTypeOperatorOrHigher, 48); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169, parseIntersectionTypeOrHigher, 49); + return parseUnionOrIntersectionType(171, parseIntersectionTypeOrHigher, 49); } function isStartOfFunctionType() { if (token() === 27) { @@ -14274,7 +14368,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85)) { - var node = createNode(171, type.pos); + var node = createNode(173, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); parseExpected(55); @@ -14396,7 +14490,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203); + var node = createNode(205); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 39 || isStartOfExpression())) { @@ -14412,11 +14506,11 @@ var ts; ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193, asyncModifier.pos); + node = createNode(195, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193, identifier.pos); + node = createNode(195, identifier.pos); } var parameter = createNode(149, identifier.pos); parameter.name = identifier; @@ -14564,7 +14658,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193); + var node = createNodeWithJSDoc(195); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; if (!fillSignature(56, isAsync, node) && !allowAmbiguity) { @@ -14595,7 +14689,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(201, leftOperand.pos); + var node = createNode(203, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -14647,39 +14741,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200, left.pos); + var node = createNode(202, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208, left.pos); + var node = createNode(210, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198); + var node = createNode(200); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194); + var node = createNode(196); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195); + var node = createNode(197); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196); + var node = createNode(198); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14694,7 +14788,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197); + var node = createNode(199); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14711,7 +14805,7 @@ var ts; if (token() === 40) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190) { + if (simpleUnaryExpression.kind === 192) { 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 { @@ -14764,7 +14858,7 @@ var ts; } function parseUpdateExpression() { if (token() === 43 || token() === 44) { - var node = createNode(198); + var node = createNode(200); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -14776,7 +14870,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199, expression.pos); + var node = createNode(201, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14795,7 +14889,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(210, fullStart); + var node = createNode(212, fullStart); node.keywordToken = 91; node.name = parseIdentifierName(); expression = finishNode(node); @@ -14819,7 +14913,7 @@ var ts; if (token() === 19 || token() === 23 || token() === 21) { return expression; } - var node = createNode(185, expression.pos); + var node = createNode(187, expression.pos); node.expression = expression; parseExpectedToken(23, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -14828,8 +14922,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257) { - var node = createNode(255, opening.pos); + if (opening.kind === 260) { + var node = createNode(258, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14838,22 +14932,22 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260) { - var node = createNode(259, opening.pos); + else if (opening.kind === 263) { + var node = createNode(262, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256); + ts.Debug.assert(opening.kind === 259); 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(200, result.pos); + var badNode = createNode(202, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -14909,7 +15003,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263); + var jsxAttributes = createNode(266); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -14917,7 +15011,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(27); if (token() === 29) { - var node_1 = createNode(260, fullStart); + var node_1 = createNode(263, fullStart); scanJsxText(); return finishNode(node_1); } @@ -14926,7 +15020,7 @@ var ts; var attributes = parseJsxAttributes(); var node; if (token() === 29) { - node = createNode(257, fullStart); + node = createNode(260, fullStart); scanJsxText(); } else { @@ -14938,7 +15032,7 @@ var ts; parseExpected(29, undefined, false); scanJsxText(); } - node = createNode(256, fullStart); + node = createNode(259, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -14950,7 +15044,7 @@ var ts; var expression = token() === 99 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23)) { - var propertyAccess = createNode(185, expression.pos); + var propertyAccess = createNode(187, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14958,7 +15052,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265); + var node = createNode(268); if (!parseExpected(17)) { return undefined; } @@ -14980,7 +15074,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262); + var node = createNode(265); node.name = parseIdentifierName(); if (token() === 58) { switch (scanJsxAttributeValue()) { @@ -14995,7 +15089,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264); + var node = createNode(267); parseExpected(17); parseExpected(24); node.expression = parseExpression(); @@ -15003,7 +15097,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258); + var node = createNode(261); parseExpected(28); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -15016,7 +15110,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261); + var node = createNode(264); parseExpected(28); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -15031,7 +15125,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190); + var node = createNode(192); parseExpected(27); node.type = parseType(); parseExpected(29); @@ -15042,7 +15136,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23); if (dotToken) { - var propertyAccess = createNode(185, expression.pos); + var propertyAccess = createNode(187, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15050,13 +15144,13 @@ var ts; } if (token() === 51 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209, expression.pos); + var nonNullExpression = createNode(211, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(21)) { - var indexedAccess = createNode(186, expression.pos); + var indexedAccess = createNode(188, expression.pos); indexedAccess.expression = expression; if (token() === 22) { indexedAccess.argumentExpression = createMissingNode(71, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -15083,7 +15177,7 @@ var ts; return token() === 13 || token() === 14; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189, tag.pos); + var tagExpression = createNode(191, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 @@ -15103,7 +15197,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187, expression.pos); + var callExpr = createNode(189, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -15111,7 +15205,7 @@ var ts; continue; } else if (token() === 19) { - var callExpr = createNode(187, expression.pos); + var callExpr = createNode(189, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15208,28 +15302,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191); + var node = createNodeWithJSDoc(193); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204); + var node = createNode(206); parseExpected(24); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 ? parseSpreadElement() : - token() === 26 ? createNode(206) : + token() === 26 ? createNode(208) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183); + var node = createNode(185); parseExpected(21); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15241,7 +15335,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); if (parseOptionalToken(24)) { - node.kind = 272; + node.kind = 275; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15262,7 +15356,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); if (isShorthandPropertyAssignment) { - node.kind = 271; + node.kind = 274; var equalsToken = parseOptionalToken(58); if (equalsToken) { node.equalsToken = equalsToken; @@ -15270,14 +15364,14 @@ var ts; } } else { - node.kind = 270; + node.kind = 273; parseExpected(56); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184); + var node = createNode(186); parseExpected(17); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15291,7 +15385,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(192); + var node = createNodeWithJSDoc(194); node.modifiers = parseModifiers(); parseExpected(89); node.asteriskToken = parseOptionalToken(39); @@ -15316,7 +15410,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94); if (parseOptional(23)) { - var node_2 = createNode(210, fullStart); + var node_2 = createNode(212, fullStart); node_2.keywordToken = 94; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -15333,7 +15427,7 @@ var ts; } break; } - var node = createNode(188, fullStart); + var node = createNode(190, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19) { @@ -15342,7 +15436,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213); + var node = createNode(216); if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15373,12 +15467,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215); + var node = createNode(218); parseExpected(25); return finishNode(node); } function parseIfStatement() { - var node = createNode(217); + var node = createNode(220); parseExpected(90); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15388,7 +15482,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218); + var node = createNode(221); parseExpected(81); node.statement = parseStatement(); parseExpected(106); @@ -15399,7 +15493,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219); + var node = createNode(222); parseExpected(106); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15423,7 +15517,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145) : parseOptional(145)) { - var forOfStatement = createNode(222, pos); + var forOfStatement = createNode(225, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -15431,14 +15525,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92)) { - var forInStatement = createNode(221, pos); + var forInStatement = createNode(224, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220, pos); + var forStatement = createNode(223, pos); forStatement.initializer = initializer; parseExpected(25); if (token() !== 25 && token() !== 20) { @@ -15456,7 +15550,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 ? 72 : 77); + parseExpected(kind === 227 ? 72 : 77); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15464,7 +15558,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225); + var node = createNode(228); parseExpected(96); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -15473,7 +15567,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226); + var node = createNode(229); parseExpected(107); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15482,7 +15576,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266); + var node = createNode(269); parseExpected(73); node.expression = allowInAnd(parseExpression); parseExpected(56); @@ -15490,7 +15584,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267); + var node = createNode(270); parseExpected(79); parseExpected(56); node.statements = parseList(3, parseStatement); @@ -15500,12 +15594,12 @@ var ts; return token() === 73 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227); + var node = createNode(230); parseExpected(98); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); - var caseBlock = createNode(241); + var caseBlock = createNode(244); parseExpected(17); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(18); @@ -15513,14 +15607,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(229); + var node = createNode(232); parseExpected(100); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(230); + var node = createNode(233); parseExpected(102); node.tryBlock = parseBlock(false); node.catchClause = token() === 74 ? parseCatchClause() : undefined; @@ -15531,7 +15625,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269); + var result = createNode(272); parseExpected(74); if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); @@ -15544,7 +15638,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231); + var node = createNode(234); parseExpected(78); parseSemicolon(); return finishNode(node); @@ -15553,12 +15647,12 @@ var ts; var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); if (expression.kind === 71 && parseOptional(56)) { - node.kind = 228; + node.kind = 231; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216; + node.kind = 219; node.expression = expression; parseSemicolon(); } @@ -15696,16 +15790,16 @@ var ts; case 17: return parseBlock(false); case 104: - return parseVariableStatement(createNodeWithJSDoc(232)); + return parseVariableStatement(createNodeWithJSDoc(235)); case 110: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232)); + return parseVariableStatement(createNodeWithJSDoc(235)); } break; case 89: - return parseFunctionDeclaration(createNodeWithJSDoc(234)); + return parseFunctionDeclaration(createNodeWithJSDoc(237)); case 75: - return parseClassDeclaration(createNodeWithJSDoc(235)); + return parseClassDeclaration(createNodeWithJSDoc(238)); case 90: return parseIfStatement(); case 81: @@ -15715,9 +15809,9 @@ var ts; case 88: return parseForOrForInOrForOfStatement(); case 77: - return parseBreakOrContinueStatement(223); + return parseBreakOrContinueStatement(226); case 72: - return parseBreakOrContinueStatement(224); + return parseBreakOrContinueStatement(227); case 96: return parseReturnStatement(); case 107: @@ -15811,7 +15905,7 @@ var ts; } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(253, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -15833,16 +15927,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 26) { - return createNode(206); + return createNode(208); } - var node = createNode(182); + var node = createNode(184); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182); + var node = createNode(184); node.dotDotDotToken = parseOptionalToken(24); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -15858,14 +15952,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180); + var node = createNode(182); parseExpected(17); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(18); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181); + var node = createNode(183); parseExpected(21); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(22); @@ -15887,7 +15981,7 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232); + var node = createNode(235); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 && token() === 51 && !scanner.hasPrecedingLineBreak()) { @@ -15900,7 +15994,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233); + var node = createNode(236); switch (token()) { case 104: break; @@ -15929,13 +16023,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20; } function parseVariableStatement(node) { - node.kind = 214; + node.kind = 217; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234; + node.kind = 237; parseExpected(89); node.asteriskToken = parseOptionalToken(39); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); @@ -16078,7 +16172,7 @@ var ts; } function parseClassElement() { if (token() === 25) { - var result = createNode(212); + var result = createNode(215); nextToken(); return finishNode(result); } @@ -16111,10 +16205,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 205); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 207); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235); + return parseClassDeclarationOrExpression(node, 238); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -16148,14 +16242,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 || tok === 108); - var node = createNode(268); + var node = createNode(271); node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207); + var node = createNode(209); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -16172,7 +16266,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236; + node.kind = 239; parseExpected(109); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -16181,7 +16275,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237; + node.kind = 240; parseExpected(139); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -16191,13 +16285,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(273); + var node = createNodeWithJSDoc(276); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238; + node.kind = 241; parseExpected(83); node.name = parseIdentifier(); if (parseExpected(17)) { @@ -16210,7 +16304,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240); + var node = createNode(243); if (parseExpected(17)) { node.statements = parseList(1, parseStatement); parseExpected(18); @@ -16221,7 +16315,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239; + node.kind = 242; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); @@ -16231,7 +16325,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239; + node.kind = 242; if (token() === 144) { node.name = parseIdentifier(); node.flags |= 512; @@ -16275,7 +16369,7 @@ var ts; return nextToken() === 41; } function parseNamespaceExportDeclaration(node) { - node.kind = 242; + node.kind = 245; parseExpected(118); parseExpected(130); node.name = parseIdentifier(); @@ -16292,7 +16386,7 @@ var ts; return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 244; + node.kind = 247; if (identifier || token() === 39 || token() === 17) { @@ -16304,7 +16398,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243; + node.kind = 246; node.name = identifier; parseExpected(58); node.moduleReference = parseModuleReference(); @@ -16312,13 +16406,13 @@ var ts; return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(245, fullStart); + var importClause = createNode(248, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(26)) { - importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(247); + importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(250); } return finishNode(importClause); } @@ -16328,7 +16422,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(254); + var node = createNode(257); parseExpected(133); parseExpected(19); node.expression = parseModuleSpecifier(); @@ -16346,7 +16440,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(246); + var namespaceImport = createNode(249); parseExpected(39); parseExpected(118); namespaceImport.name = parseIdentifier(); @@ -16354,14 +16448,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 247 ? parseImportSpecifier : parseExportSpecifier, 17, 18); + node.elements = parseBracketedList(22, kind === 250 ? parseImportSpecifier : parseExportSpecifier, 17, 18); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252); + return parseImportOrExportSpecifier(255); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248); + return parseImportOrExportSpecifier(251); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16380,19 +16474,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 && checkIdentifierIsKeyword) { + if (kind === 251 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250; + node.kind = 253; if (parseOptional(39)) { parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251); + node.exportClause = parseNamedImportsOrExports(254); if (token() === 143 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); @@ -16402,7 +16496,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249; + node.kind = 252; if (parseOptional(58)) { node.isExportEquals = true; } @@ -16420,10 +16514,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 243 && node.moduleReference.kind === 254 - || node.kind === 244 - || node.kind === 249 - || node.kind === 250 + || node.kind === 246 && node.moduleReference.kind === 257 + || node.kind === 247 + || node.kind === 252 + || node.kind === 253 ? node : undefined; } @@ -16452,7 +16546,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278, scanner.getTokenPos()); + var result = createNode(281, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -16500,15 +16594,14 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - if (!isJSDocLikeText(content, start)) { - return result; - } - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { var state = 1; var margin; var indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4; @@ -16581,9 +16674,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -16595,7 +16687,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286, start); + var result = createNode(289, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -16707,6 +16799,16 @@ var ts; indent += whitespace.length; } break; + case 17: + state = 2; + if (lookAhead(function () { return nextJSDocToken() === 57 && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39: if (state === 0) { state = 1; @@ -16725,7 +16827,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289, atToken.pos); + var result = createNode(292, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -16782,8 +16884,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(299, atToken.pos) : - createNode(293, atToken.pos); + createNode(302, atToken.pos) : + createNode(296, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -16803,18 +16905,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281, 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 === 293 || child.kind === 299) { + if (child.kind === 296 || child.kind === 302) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287, start_2); + jsdocTypeLiteral = createNode(290, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167) { jsdocTypeLiteral.isArrayType = true; @@ -16825,27 +16927,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294, atToken.pos); + var result = createNode(297, 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 === 296; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296, atToken.pos); + var result = createNode(299, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290, atToken.pos); + var result = createNode(293, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -16853,7 +16955,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17); - var node = createNode(207); + var node = createNode(209); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -16865,7 +16967,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23)) { - var prop = createNode(185, node.pos); + var prop = createNode(187, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -16873,13 +16975,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291, atToken.pos); + var tag = createNode(294, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295, atToken.pos); + var tag = createNode(298, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); @@ -16889,7 +16991,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298, atToken.pos); + var typedefTag = createNode(301, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -16905,9 +17007,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287, start_3); + jsdocTypeLiteral = createNode(290, start_3); } - if (child.kind === 296) { + if (child.kind === 299) { if (childTypeTag) { break; } @@ -16938,7 +17040,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23)) { - var jsDocNamespaceNode = createNode(239, pos); + var jsDocNamespaceNode = createNode(242, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -16952,7 +17054,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292, atToken.pos); + var callbackTag = createNode(295, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -16961,7 +17063,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288, start); + var jsdocSignature = createNode(291, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -16969,7 +17071,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57)) { var tag = parseTag(indent); - if (tag && tag.kind === 294) { + if (tag && tag.kind === 297) { return tag; } } @@ -17014,9 +17116,9 @@ var ts; case 57: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 && + if (child && (child.kind === 296 || child.kind === 302) && target !== 4 && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -17089,7 +17191,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297, atToken.pos); + var result = createNode(300, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -17678,6 +17780,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; ts.libs = libEntries.map(function (entry) { return entry[0]; }); ts.libMap = ts.createMapFromEntries(libEntries); @@ -18768,7 +18871,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 !== 270) { + if (element.kind !== 273) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -18839,13 +18942,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198: + case 200: if (valueExpression.operator !== 38 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 184: + case 186: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -18855,7 +18958,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 183: + case 185: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -20557,21 +20660,21 @@ var ts; ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateWorker(node) { switch (node.kind) { - case 236: - case 237: + case 239: + case 240: return 0; - case 238: - if (ts.isConst(node)) { + case 241: + if (ts.isEnumConst(node)) { return 2; } break; - case 244: - case 243: + case 247: + case 246: if (!(ts.hasModifier(node, 1))) { return 0; } break; - case 240: { + case 243: { var state_1 = 0; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -20590,7 +20693,7 @@ var ts; }); return state_1; } - case 239: + case 242: return getModuleInstanceState(node); case 71: if (node.isInJSDocNamespace) { @@ -20707,7 +20810,7 @@ var ts; } } function getDeclarationName(node) { - if (node.kind === 249) { + if (node.kind === 252) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -20731,27 +20834,27 @@ var ts; return "__constructor"; case 163: case 158: - case 288: + case 291: return "__call"; case 164: case 159: return "__new"; case 160: return "__index"; - case 250: + case 253: return "__export"; - case 274: + case 277: return "export="; - case 200: + case 202: if (ts.getSpecialPropertyAssignmentKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284: + case 287: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); 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"; }); + ts.Debug.assert(node.parent.kind === 287, "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; @@ -20801,7 +20904,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 249 && !node.isExportEquals)) { + (node.kind === 252 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20826,7 +20929,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 2097152) { - if (node.kind === 252 || (node.kind === 243 && hasExportModifier)) { + if (node.kind === 255 || (node.kind === 246 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20856,7 +20959,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 193) { + if (node.kind !== 195) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -20896,7 +20999,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 274) { + if (node.kind === 277) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -20945,8 +21048,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -20978,76 +21081,77 @@ var ts; return; } switch (node.kind) { - case 219: + case 222: bindWhileStatement(node); break; - case 218: + case 221: bindDoStatement(node); break; - case 220: + case 223: bindForStatement(node); break; - case 221: - case 222: + case 224: + case 225: bindForInOrForOfStatement(node); break; - case 217: + case 220: bindIfStatement(node); break; - case 225: - case 229: + case 228: + case 232: bindReturnOrThrow(node); break; - case 224: - case 223: + case 227: + case 226: bindBreakOrContinueStatement(node); break; - case 230: + case 233: bindTryStatement(node); break; - case 227: + case 230: bindSwitchStatement(node); break; - case 241: + case 244: bindCaseBlock(node); break; - case 266: + case 269: bindCaseClause(node); break; - case 228: + case 231: bindLabeledStatement(node); break; - case 198: + case 200: bindPrefixUnaryExpressionFlow(node); break; - case 199: + case 201: bindPostfixUnaryExpressionFlow(node); break; - case 200: + case 202: bindBinaryExpressionFlow(node); break; - case 194: + case 196: bindDeleteExpressionFlow(node); break; - case 201: + case 203: bindConditionalExpressionFlow(node); break; - case 232: + case 235: bindVariableDeclarationFlow(node); break; - case 187: + case 189: bindCallExpressionFlow(node); break; - case 298: - case 292: + case 301: + case 295: bindJSDocTypeAlias(node); break; - case 274: + case 277: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213: - case 240: + } + case 216: + case 243: bindEachFunctionsFirst(node.statements); break; default: @@ -21060,15 +21164,15 @@ var ts; switch (expr.kind) { case 71: case 99: - case 185: - return isNarrowableReference(expr); case 187: + return isNarrowableReference(expr); + case 189: return hasNarrowableArgument(expr); - case 191: + case 193: return isNarrowingExpression(expr.expression); - case 200: + case 202: return isNarrowingBinaryExpression(expr); - case 198: + case 200: return expr.operator === 51 && isNarrowingExpression(expr.operand); } return false; @@ -21077,7 +21181,7 @@ var ts; return expr.kind === 71 || expr.kind === 99 || expr.kind === 97 || - expr.kind === 185 && isNarrowableReference(expr.expression); + expr.kind === 187 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -21088,7 +21192,7 @@ var ts; } } } - if (expr.expression.kind === 185 && + if (expr.expression.kind === 187 && isNarrowableReference(expr.expression.expression)) { return true; } @@ -21121,9 +21225,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191: + case 193: return isNarrowableOperand(expr.expression); - case 200: + case 202: switch (expr.operatorToken.kind) { case 58: return isNarrowableOperand(expr.left); @@ -21200,33 +21304,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217: - case 219: - case 218: - return parent.expression === node; case 220: - case 201: + case 222: + case 221: + return parent.expression === node; + case 223: + case 203: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191) { + if (node.kind === 193) { node = node.expression; } - else if (node.kind === 198 && node.operator === 51) { + else if (node.kind === 200 && node.operator === 51) { node = node.operand; } else { - return node.kind === 200 && (node.operatorToken.kind === 53 || + return node.kind === 202 && (node.operatorToken.kind === 53 || node.operatorToken.kind === 54); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 || - node.parent.kind === 198 && + while (node.parent.kind === 193 || + node.parent.kind === 200 && node.parent.operator === 51) { node = node.parent; } @@ -21268,7 +21372,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 + var enclosingLabeledStatement = node.parent.kind === 231 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -21300,13 +21404,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222) { + if (node.kind === 225) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233) { + if (node.initializer.kind !== 236) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21328,7 +21432,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225) { + if (node.kind === 228) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21348,7 +21452,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21411,7 +21515,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -21477,13 +21581,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218) { + if (!node.statement || node.statement.kind !== 221) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 && node.operatorToken.kind === 58) { + if (node.kind === 202 && node.operatorToken.kind === 58) { bindAssignmentTargetFlow(node.left); } else { @@ -21494,10 +21598,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183) { + else if (node.kind === 185) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204) { + if (e.kind === 206) { bindAssignmentTargetFlow(e.expression); } else { @@ -21505,16 +21609,16 @@ var ts; } } } - else if (node.kind === 184) { + else if (node.kind === 186) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270) { + if (p.kind === 273) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271) { + else if (p.kind === 274) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272) { + else if (p.kind === 275) { bindAssignmentTargetFlow(p.expression); } } @@ -21570,7 +21674,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 && node.left.kind === 186) { + if (operator === 58 && node.left.kind === 188) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21581,7 +21685,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185) { + if (node.expression.kind === 187) { bindAssignmentTargetFlow(node.expression); } } @@ -21625,10 +21729,10 @@ var ts; } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 191) { + while (expr.kind === 193) { expr = expr.expression; } - if (expr.kind === 192 || expr.kind === 193) { + if (expr.kind === 194 || expr.kind === 195) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -21636,7 +21740,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185) { + if (node.expression.kind === 187) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21645,53 +21749,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205: - case 235: + case 207: case 238: - case 184: + case 241: + case 186: case 166: - case 287: - case 263: + case 290: + case 266: return 1; - case 236: - return 1 | 64; case 239: - case 237: - case 177: + return 1 | 64; + case 242: + case 240: + case 179: return 1 | 32; - case 274: + case 277: return 1 | 4 | 32; case 154: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } case 155: - case 234: + case 237: case 153: case 156: case 157: case 158: - case 288: - case 284: + case 291: + case 287: case 163: case 159: case 160: case 164: return 1 | 4 | 32 | 8; - case 192: - case 193: + case 194: + case 195: return 1 | 4 | 32 | 8 | 16; - case 240: + case 243: return 4; case 152: return node.initializer ? 4 : 0; - case 269: - case 220: - case 221: - case 222: - case 241: + case 272: + case 223: + case 224: + case 225: + case 244: return 2; - case 213: + case 216: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -21704,40 +21808,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 239: + case 242: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274: + case 277: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205: - case 235: - return declareClassMember(node, symbolFlags, symbolExcludes); + case 207: case 238: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 241: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166: - case 287: - case 184: - case 236: - case 263: + case 290: + case 186: + case 239: + case 266: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 163: case 164: case 158: case 159: - case 288: + case 291: case 160: case 154: case 153: case 155: case 156: case 157: - case 234: - case 192: - case 193: - case 284: - case 298: - case 292: case 237: - case 177: + case 194: + case 195: + case 287: + case 301: + case 295: + case 240: + case 179: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -21752,11 +21856,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 ? node : node.body; - if (body && (body.kind === 274 || body.kind === 240)) { + var body = node.kind === 277 ? node : node.body; + if (body && (body.kind === 277 || body.kind === 243)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 || stat.kind === 249) { + if (stat.kind === 253 || stat.kind === 252) { return true; } } @@ -21824,11 +21928,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 === 272 || prop.name.kind !== 71) { + if (prop.kind === 275 || prop.name.kind !== 71) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 270 || prop.kind === 271 || prop.kind === 154 + var currentKind = prop.kind === 273 || prop.kind === 274 || prop.kind === 154 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -21860,10 +21964,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239: + case 242: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274: + case 277: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21983,8 +22087,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 274 && - blockScopeContainer.kind !== 239 && + if (blockScopeContainer.kind !== 277 && + blockScopeContainer.kind !== 242 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -22048,7 +22152,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -22098,11 +22206,11 @@ var ts; break; } case 99: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185: + case 187: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -22110,7 +22218,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200: + case 202: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1: @@ -22137,19 +22245,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269: + case 272: return checkStrictModeCatchClause(node); - case 194: + case 196: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 199: + case 201: return checkStrictModePostfixUnaryExpression(node); - case 198: + case 200: return checkStrictModePrefixUnaryExpression(node); - case 226: + case 229: return checkStrictModeWithStatement(node); - case 174: + case 176: seenThisKeyword = true; return; case 161: @@ -22158,18 +22266,18 @@ var ts; return bindTypeParameter(node); case 149: return bindParameter(node); - case 232: + case 235: return bindVariableDeclarationOrBindingElement(node); - case 182: + case 184: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152: case 151: return bindPropertyWorker(node); - case 270: - case 271: - return bindPropertyOrMethodOrAccessor(node, 4, 0); case 273: + case 274: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 276: return bindPropertyOrMethodOrAccessor(node, 8, 68008959); case 158: case 159: @@ -22178,7 +22286,7 @@ var ts; case 154: case 153: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67208127); - case 234: + case 237: return bindFunctionDeclaration(node); case 155: return declareSymbolAndAddToSymbolTable(node, 16384, 0); @@ -22187,77 +22295,77 @@ var ts; case 157: return bindPropertyOrMethodOrAccessor(node, 65536, 67183551); case 163: - case 284: - case 288: + case 287: + case 291: case 164: return bindFunctionOrConstructorType(node); case 166: - case 287: - case 177: + case 290: + case 179: return bindAnonymousTypeWorker(node); - case 184: + case 186: return bindObjectLiteralExpression(node); - case 192: - case 193: + case 194: + case 195: return bindFunctionExpression(node); - case 187: + case 189: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 205: - case 235: + case 207: + case 238: inStrictMode = true; return bindClassLikeDeclaration(node); - case 236: - return bindBlockScopedDeclaration(node, 64, 67901832); - case 237: - return bindBlockScopedDeclaration(node, 524288, 67901928); - case 238: - return bindEnumDeclaration(node); case 239: - return bindModuleDeclaration(node); - case 263: - return bindJsxAttributes(node); - case 262: - return bindJsxAttribute(node, 4, 0); - case 243: - case 246: - case 248: - case 252: - return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); + return bindBlockScopedDeclaration(node, 64, 67901832); + case 240: + return bindBlockScopedDeclaration(node, 524288, 67901928); + case 241: + return bindEnumDeclaration(node); case 242: - return bindNamespaceExportDeclaration(node); - case 245: - return bindImportClause(node); - case 250: - return bindExportDeclaration(node); + return bindModuleDeclaration(node); + case 266: + return bindJsxAttributes(node); + case 265: + return bindJsxAttribute(node, 4, 0); + case 246: case 249: + case 251: + case 255: + return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); + case 245: + return bindNamespaceExportDeclaration(node); + case 248: + return bindImportClause(node); + case 253: + return bindExportDeclaration(node); + case 252: return bindExportAssignment(node); - case 274: + case 277: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213: + case 216: if (!ts.isFunctionLike(node.parent)) { return; } - case 240: + case 243: return updateStrictModeStatementList(node.statements); - case 293: - if (node.parent.kind === 288) { + case 296: + if (node.parent.kind === 291) { return bindParameter(node); } - if (node.parent.kind !== 287) { + if (node.parent.kind !== 290) { break; } - case 299: + case 302: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 298: - case 292: + case 301: + case 295: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -22287,7 +22395,7 @@ var ts; bindAnonymousDeclaration(node, 2097152, getDeclarationName(node)); } else { - var flags = node.kind === 249 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 && ts.exportAssignmentIsAlias(node) ? 2097152 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863); @@ -22297,7 +22405,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274) { + if (node.parent.kind !== 277) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -22373,8 +22481,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 234: - case 192: + case 237: + case 194: var constructorSymbol = thisContainer.symbol; if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58) { var l = thisContainer.parent.left; @@ -22396,7 +22504,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); break; - case 274: + case 277: break; default: ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer)); @@ -22406,7 +22514,7 @@ var ts; if (node.expression.kind === 99) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -22447,9 +22555,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274; + : propertyAccess.parent.parent.kind === 277; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920)) && isToplevelNamespaceableInitializer) { var flags_1 = 1536 | 67108864; var excludeFlags_1 = 67215503 & ~67108864; @@ -22528,7 +22636,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235) { + if (node.kind === 238) { bindBlockScopedDeclaration(node, 32, 68008383); } else { @@ -22551,7 +22659,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128, 68008831) : bindBlockScopedDeclaration(node, 256, 68008191); } @@ -22572,7 +22680,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 && container.kind !== 288) { + if (node.kind === 296 && container.kind !== 291) { return; } if (inStrictMode && !(node.flags & 4194304)) { @@ -22645,7 +22753,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144, 67639784); } } - else if (node.parent.kind === 172) { + else if (node.parent.kind === 174) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -22670,10 +22778,10 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 215) || - node.kind === 235 || - (node.kind === 239 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 238 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 218) || + node.kind === 238 || + (node.kind === 242 && shouldReportErrorOnModuleDeclaration(node)) || + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -22714,43 +22822,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187: + case 189: return computeCallExpression(node, subtreeFlags); - case 188: + case 190: return computeNewExpression(node, subtreeFlags); - case 239: + case 242: return computeModuleDeclaration(node, subtreeFlags); - case 191: + case 193: return computeParenthesizedExpression(node, subtreeFlags); - case 200: + case 202: return computeBinaryExpression(node, subtreeFlags); - case 216: + case 219: return computeExpressionStatement(node, subtreeFlags); case 149: return computeParameter(node, subtreeFlags); - case 193: + case 195: return computeArrowFunction(node, subtreeFlags); - case 192: + case 194: return computeFunctionExpression(node, subtreeFlags); - case 234: + case 237: 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 computeVariableDeclaration(node, subtreeFlags); + case 236: + return computeVariableDeclarationList(node, subtreeFlags); + case 217: + return computeVariableStatement(node, subtreeFlags); + case 231: + return computeLabeledStatement(node, subtreeFlags); + case 238: return computeClassDeclaration(node, subtreeFlags); - case 205: - return computeClassExpression(node, subtreeFlags); - case 268: - return computeHeritageClause(node, subtreeFlags); - case 269: - return computeCatchClause(node, subtreeFlags); case 207: + return computeClassExpression(node, subtreeFlags); + case 271: + return computeHeritageClause(node, subtreeFlags); + case 272: + return computeCatchClause(node, subtreeFlags); + case 209: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155: return computeConstructor(node, subtreeFlags); @@ -22761,11 +22869,11 @@ var ts; case 156: case 157: return computeAccessor(node, subtreeFlags); - case 243: + case 246: return computeImportEquals(node, subtreeFlags); - case 185: + case 187: return computePropertyAccess(node, subtreeFlags); - case 186: + case 188: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -22809,10 +22917,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 && leftKind === 184) { + if (operatorTokenKind === 58 && leftKind === 186) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 58 && leftKind === 183) { + else if (operatorTokenKind === 58 && leftKind === 185) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 40 @@ -22850,8 +22958,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 208 - || expressionKind === 190) { + if (expressionKind === 210 + || expressionKind === 192) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -23150,12 +23258,12 @@ var ts; var excludeFlags = 939525441; switch (kind) { case 120: - case 197: + case 199: transformFlags |= 8 | 16; break; - case 190: - case 208: - case 302: + case 192: + case 210: + case 305: transformFlags |= 3; excludeFlags = 536872257; break; @@ -23165,35 +23273,35 @@ var ts; case 117: case 124: case 76: - case 238: - case 273: - case 209: + case 241: + case 276: + case 211: case 132: transformFlags |= 3; break; - case 255: - case 256: - case 257: - case 10: case 258: case 259: case 260: + case 10: case 261: case 262: case 263: case 264: case 265: + case 266: + case 267: + case 268: transformFlags |= 4; break; case 13: case 14: case 15: case 16: - case 202: - case 189: - case 271: + case 204: + case 191: + case 274: case 115: - case 210: + case 212: transformFlags |= 192; break; case 9: @@ -23206,13 +23314,13 @@ var ts; transformFlags |= 192; } break; - case 222: + case 225: if (node.awaitModifier) { transformFlags |= 8; } transformFlags |= 192; break; - case 203: + case 205: transformFlags |= 8 | 192 | 16777216; break; case 119: @@ -23242,14 +23350,16 @@ var ts; case 171: case 172: case 173: - case 236: - case 237: case 174: case 175: + case 239: + case 240: case 176: case 177: case 178: - case 242: + case 179: + case 180: + case 245: transformFlags = 3; excludeFlags = -3; break; @@ -23259,10 +23369,10 @@ var ts; transformFlags |= 65536; } break; - case 204: + case 206: transformFlags |= 192 | 524288; break; - case 272: + case 275: transformFlags |= 8 | 1048576; break; case 97: @@ -23272,18 +23382,18 @@ var ts; case 99: transformFlags |= 16384; break; - case 180: + case 182: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 940049729; break; - case 181: + case 183: transformFlags |= 192 | 8388608; excludeFlags = 940049729; break; - case 182: + case 184: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; @@ -23292,7 +23402,7 @@ var ts; case 150: transformFlags |= 3 | 4096; break; - case 184: + case 186: excludeFlags = 942740801; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -23304,31 +23414,31 @@ var ts; transformFlags |= 8; } break; - case 183: - case 188: + case 185: + case 190: excludeFlags = 940049729; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 218: - case 219: - case 220: case 221: + case 222: + case 223: + case 224: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 274: + case 277: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 225: + case 228: transformFlags |= 33554432 | 8; break; - case 223: - case 224: + case 226: + case 227: transformFlags |= 33554432; break; } @@ -23336,27 +23446,27 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 && kind <= 179) { + if (kind >= 161 && kind <= 181) { return -3; } switch (kind) { - case 187: - case 188: - case 183: + case 189: + case 190: + case 185: return 940049729; - case 239: + case 242: return 977327425; case 149: return 939525441; - case 193: + case 195: return 1003902273; - case 192: - case 234: + case 194: + case 237: return 1003935041; - case 233: + case 236: return 948962625; - case 235: - case 205: + case 238: + case 207: return 942011713; case 155: return 1003668801; @@ -23378,24 +23488,24 @@ var ts; case 158: case 159: case 160: - case 236: - case 237: + case 239: + case 240: return -3; - case 184: + case 186: return 942740801; - case 269: + case 272: return 940574017; - case 180: - case 181: + case 182: + case 183: return 940049729; - case 190: - case 208: - case 302: - case 191: + case 192: + case 210: + case 305: + case 193: case 97: return 536872257; - case 185: - case 186: + case 187: + case 188: return 671089985; default: return 939525441; @@ -23653,6 +23763,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -23726,7 +23837,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -23822,6 +23932,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -23876,7 +23987,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -23931,6 +24042,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; var patternAmbientModules; @@ -24028,140 +24140,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - 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) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildParameterDisplay: function (symbol, writer, enclosing, flags) { - var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { - var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 | 8192, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { - var printer = ts.createPrinter({ removeComments: true }); - var flags = 8192 | 3112960 | 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); }))); - printer.writeList(1296, 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)); })); - printer.writeList(26896, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -24197,6 +24175,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -24315,22 +24318,56 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { - var message_2 = target.flags & 384 || source.flags & 384 + var isEitherEnum = !!(target.flags & 384 || source.flags & 384); + var isEitherBlockScoped = !!(target.flags & 2 || source.flags & 2); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 || source.flags & 2 + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -24397,7 +24434,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -24443,15 +24480,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 182) { - var errorBindingElement = ts.getAncestor(usage, 182); + if (declaration.kind === 184) { + var errorBindingElement = ts.getAncestor(usage, 184); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 232), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235), usage); } - else if (declaration.kind === 232) { + else if (declaration.kind === 235) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -24459,10 +24496,10 @@ var ts; } return true; } - if (usage.parent.kind === 252 || (usage.parent.kind === 249 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 || (usage.parent.kind === 252 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 249 && usage.isExportEquals) { + if (usage.kind === 252 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -24470,9 +24507,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214: - case 220: - case 222: + case 217: + case 223: + case 225: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } @@ -24527,7 +24564,7 @@ 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 !== 286) { + if (meaning & result.flags & 67901928 && lastLocation.kind !== 289) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 149 || @@ -24541,7 +24578,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171) { + else if (location.kind === 173) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -24553,13 +24590,13 @@ var ts; } } switch (location.kind) { - case 274: + case 277: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 239: + case 242: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 || ts.isAmbientModule(location)) { + if (location.kind === 277 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -24570,7 +24607,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - ts.getDeclarationOfKind(moduleExport, 252)) { + ts.getDeclarationOfKind(moduleExport, 255)) { break; } } @@ -24583,7 +24620,7 @@ var ts; } } break; - case 238: + case 241: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } @@ -24599,9 +24636,9 @@ var ts; } } break; - case 235: - case 205: - case 236: + case 238: + case 207: + case 239: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -24613,7 +24650,7 @@ var ts; } break loop; } - if (location.kind === 205 && meaning & 32) { + if (location.kind === 207 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -24621,7 +24658,7 @@ var ts; } } break; - case 207: + case 209: 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))) { @@ -24634,7 +24671,7 @@ var ts; break; case 147: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239) { 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; @@ -24646,14 +24683,14 @@ var ts; case 155: case 156: case 157: - case 234: - case 193: + case 237: + case 195: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192: + case 194: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -24674,8 +24711,8 @@ var ts; location = location.parent; } break; - case 298: - case 292: + case 301: + case 295: location = ts.getJSDocHost(location); break; } @@ -24690,7 +24727,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274); + ts.Debug.assert(lastLocation.kind === 277); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -24749,7 +24786,7 @@ var ts; } if (result && isInExternalModule && (meaning & 67216319) === 67216319 && !(originalLocation.flags & 2097152)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 242) { + if (decls && decls.length === 1 && decls[0].kind === 245) { 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)); } } @@ -24758,12 +24795,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234: - case 235: - case 236: - case 238: case 237: + case 238: case 239: + case 241: + case 240: + case 242: return true; default: return false; @@ -24824,9 +24861,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71: - case 185: + case 187: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207: + case 209: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -24888,18 +24925,26 @@ 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 === 238) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -24908,13 +24953,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243: - return node; - case 245: - return node.parent; case 246: - return node.parent.parent; + return node; case 248: + return node.parent; + case 249: + return node.parent.parent; + case 251: return node.parent.parent.parent; default: return undefined; @@ -24924,7 +24969,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254) { + if (node.moduleReference.kind === 257) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -25079,20 +25124,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243: - return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245: - return getTargetOfImportClause(node, dontRecursivelyResolve); case 246: - return getTargetOfNamespaceImport(node, dontRecursivelyResolve); + return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); case 248: - return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252: - return getTargetOfExportSpecifier(node, 67216319 | 67901928 | 1920, dontRecursivelyResolve); + return getTargetOfImportClause(node, dontRecursivelyResolve); case 249: - case 200: + return getTargetOfNamespaceImport(node, dontRecursivelyResolve); + case 251: + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 255: + return getTargetOfExportSpecifier(node, 67216319 | 67901928 | 1920, dontRecursivelyResolve); + case 252: + case 202: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242: + case 245: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -25146,10 +25191,10 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249) { + if (node.kind === 252) { checkExpressionCached(node.expression); } - else if (node.kind === 252) { + else if (node.kind === 255) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -25165,7 +25210,7 @@ var ts; return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 243); + ts.Debug.assert(entityName.parent.kind === 246); return resolveEntityName(entityName, 67216319 | 67901928 | 1920, false, dontResolveAlias); } } @@ -25186,7 +25231,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 || name.kind === 185) { + else if (name.kind === 146 || name.kind === 187) { 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); @@ -25340,9 +25385,18 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages(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)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages(undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : 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)) + : undefined; 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)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -25365,7 +25419,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 | 3))) { + if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 277)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -25583,6 +25637,12 @@ var ts; var type = createType(131072); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -25597,25 +25657,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -25630,11 +25684,11 @@ var ts; } } switch (location.kind) { - case 274: + case 277: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 239: + case 242: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -25712,7 +25766,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -25797,10 +25851,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25845,8 +25899,8 @@ var ts; entityName.parent.kind === 147) { meaning = 67216319 | 1048576; } - else if (entityName.kind === 146 || entityName.kind === 185 || - entityName.parent.kind === 243) { + else if (entityName.kind === 146 || entityName.kind === 187 || + entityName.parent.kind === 246) { meaning = 1920; } else { @@ -25924,64 +25978,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -25989,6 +26012,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -26105,7 +26130,7 @@ var ts; 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 & 262144 ? 169 : 170, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 ? 171 : 172, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -26169,7 +26194,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 === 205 && context.flags & 2048) || + else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319); @@ -26202,7 +26227,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 || declaration.parent.kind === 240; + return declaration.parent.kind === 277 || declaration.parent.kind === 243; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || (context.visitedSymbols && context.visitedSymbols.has(id))) && @@ -26249,8 +26274,15 @@ var ts; } else if (type.target.objectFlags & 8) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -26447,7 +26479,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 === 155); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -26501,7 +26533,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -26509,7 +26541,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; - var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192; var dotDotDotToken = isRest ? ts.createToken(24) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -26518,7 +26550,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096; + var questionToken = isOptional ? ts.createToken(55) : undefined; var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined); return parameterNode; function cloneBindingName(node) { @@ -26526,7 +26559,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 === 182) { + if (clone.kind === 184) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 | 16777216); @@ -26600,16 +26633,45 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277); + if (file && file.moduleName !== undefined) { + return file.moduleName; + } + if (!file) { + 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, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384)); - context.flags |= 16777216; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216; var isTypeOf = meaning === 67216319; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -26782,8 +26844,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 !== 173; }); - if (node.kind === 237) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175; }); + if (node.kind === 240) { return getSymbolOfNode(node); } } @@ -26791,11 +26853,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 && + node.parent.kind === 243 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 || ts.isAmbientModule(location); + return location.kind === 277 || ts.isAmbientModule(location); } function getNameOfSymbolAsWritten(symbol, context) { if (context && symbol.escapedName === "default" && !(context.flags & 16384) && @@ -26805,41 +26867,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { - var file = ts.getDeclarationOfKind(symbol, 274); - if (!file || !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); - } - } - } - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232) { + if (declaration.parent && declaration.parent.kind === 235) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205: - return "(Anonymous class)"; - case 192: - case 193: - return "(Anonymous function)"; + case 207: + case 194: + case 195: + if (context && !context.encounteredError && !(context.flags & 131072)) { + context.encounteredError = true; + } + return declaration.kind === 207 ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -26864,29 +26907,29 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292: - case 298: + case 295: + case 301: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 182: + case 184: return isDeclarationVisible(node.parent.parent); - case 232: + case 235: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 239: - case 235: - case 236: - case 237: - case 234: + case 242: case 238: - case 243: + case 239: + case 240: + case 237: + case 241: + case 246: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 243 && parent.kind !== 274 && parent.flags & 4194304)) { + !(node.kind !== 246 && parent.kind !== 277 && parent.flags & 4194304)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); @@ -26904,26 +26947,26 @@ var ts; case 158: case 160: case 149: - case 240: + case 243: case 163: case 164: case 166: case 162: case 167: case 168: - case 169: - case 170: - case 173: + case 171: + case 172: + case 175: return isDeclarationVisible(node.parent); - case 245: - case 246: case 248: + case 249: + case 251: return false; case 148: - case 274: - case 242: + case 277: + case 245: return true; - case 249: + case 252: return false; default: return false; @@ -26932,10 +26975,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249) { + if (node.parent && node.parent.kind === 252) { exportSymbol = resolveName(node, node.escapedText, 67216319 | 67901928 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 252) { + else if (node.parent.kind === 255) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 | 67901928 | 1920 | 2097152); } var result; @@ -27016,12 +27059,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232: - case 233: + case 235: + case 236: + case 251: + case 250: + case 249: case 248: - case 247: - case 246: - case 245: return false; default: return true; @@ -27086,7 +27129,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180) { + if (pattern.kind === 182) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -27149,20 +27192,23 @@ var ts; } else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false, false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - type = createArrayType(elementType); + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -27171,7 +27217,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192)) { type = getTypeWithFacts(type, 131072); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2) : type; } @@ -27188,18 +27234,18 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 && expr.elements.length === 0; + return expr.kind === 185 && 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 === 221) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224) { 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) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } @@ -27213,7 +27259,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 4194304)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -27271,18 +27317,18 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 ? declaration : - declaration.kind === 185 ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : ts.getSpecialPropertyAssignmentKind(expression); if (special === 4) { var thisContainer = ts.getThisContainer(expression, false); declarationInConstructor = thisContainer.kind === 155 || - thisContainer.kind === 234 || - (thisContainer.kind === 192 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 || + (thisContainer.kind === 194 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -27302,7 +27348,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 && special === 2 && @@ -27378,7 +27424,7 @@ var ts; } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -27420,11 +27466,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -27434,7 +27482,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 + return pattern.kind === 182 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -27487,7 +27535,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 === 249) { + if (declaration.kind === 252) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol, 0)) { @@ -27678,8 +27726,8 @@ var ts; if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 || - symbol.valueDeclaration.kind === 185 && symbol.valueDeclaration.parent.kind === 200) { + else if (symbol.valueDeclaration.kind === 202 || + symbol.valueDeclaration.kind === 187 && symbol.valueDeclaration.parent.kind === 202) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -27804,51 +27852,51 @@ var ts; return undefined; } switch (node.kind) { - case 235: - case 205: - case 236: + case 238: + case 207: + case 239: case 158: case 159: case 153: case 163: case 164: - case 284: - case 234: - case 154: - case 192: - case 193: + case 287: case 237: - case 297: - case 298: - case 292: - case 177: - case 171: + case 154: + case 194: + case 195: + case 240: + case 300: + case 301: + case 295: + case 179: + case 173: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177) { + if (node.kind === 179) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171) { + else if (node.kind === 173) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 || node.kind === 205 || node.kind === 236) && + (node.kind === 238 || node.kind === 207 || node.kind === 239) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 236); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239); 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 === 236 || - node.kind === 235 || - node.kind === 205 || + if (node.kind === 239 || + node.kind === 238 || + node.kind === 207 || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -27878,14 +27926,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -27900,7 +27941,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -27931,7 +27972,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 | 64)) { if (type.symbol.flags & 32) { @@ -28005,7 +28046,7 @@ var ts; 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 === 236 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -28034,7 +28075,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236) { + if (declaration.kind === 239) { if (declaration.flags & 64) { return false; } @@ -28085,7 +28126,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237; + return ts.isJSDocTypeAlias(d) || d.kind === 240; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -28109,7 +28150,7 @@ var ts; if (expr.kind === 9) { return true; } - else if (expr.kind === 200) { + else if (expr.kind === 202) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -28123,12 +28164,12 @@ var ts; case 9: case 8: return true; - case 198: + case 200: return expr.operator === 38 && expr.operand.kind === 8; case 71: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 200: + case 202: return isStringConcatExpression(expr); default: return false; @@ -28142,7 +28183,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238) { + if (declaration.kind === 241) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9) { @@ -28169,7 +28210,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238) { + if (declaration.kind === 241) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); @@ -28254,7 +28295,7 @@ var ts; case 140: case 95: case 131: - case 178: + case 180: return true; case 167: return isThislessType(node.elementType); @@ -28533,6 +28574,28 @@ var ts; function cloneSignature(sig) { return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 : + i >= minLength_1 ? 4096 : 0; + var symbol = createSymbol(1, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1); @@ -28688,6 +28751,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper); @@ -28696,6 +28760,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call")); var constructSignatures = getSignaturesOfSymbol(members.get("__new")); @@ -28832,7 +28897,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 175 && + return constraintDeclaration.kind === 177 && constraintDeclaration.operator === 128; } function getModifiersTypeFromMappedType(type) { @@ -28940,6 +29005,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144)) { @@ -29329,10 +29405,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJavaScriptFile(node) && (node.type && node.type.kind === 283 + return ts.isInJavaScriptFile(node) && (node.type && node.type.kind === 286 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -29350,7 +29426,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -29365,7 +29441,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -29448,7 +29524,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178) { + if (type && type.kind === 180) { hasLiteralTypes = true; } var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -29488,9 +29564,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3, "args"); + var syntheticArgsSymbol = createSymbol(3, "args", 8192); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { parameters.pop(); } @@ -29590,9 +29665,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -29635,16 +29710,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -29735,22 +29807,28 @@ 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 === 172 && declaration.parent.parent.kind === 162) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174) { + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + else if (grandParent.kind === 149 && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -29838,7 +29916,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 !== 290; + var missingAugmentsTag = isJs && node.parent.kind !== 293; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -29888,7 +29966,7 @@ var ts; switch (node.kind) { case 162: return node.typeName; - case 207: + case 209: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -29970,9 +30048,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286) { + while (node && !ts.isStatement(node) && node.kind !== 289) { var parent = node.parent; - if (parent.kind === 171 && node === parent.trueType) { + if (parent.kind === 173 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -30078,9 +30156,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235: - case 236: case 238: + case 239: + case 241: return declaration; } } @@ -30190,18 +30268,26 @@ var ts; } return links.resolvedType; } - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536); - typeParameters.push(typeParameter); - var property = createSymbol(4, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536); + if (i < maxLength) { + var property = createSymbol(4 | (i >= minLength ? 16777216 : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 | 4); type.typeParameters = typeParameters; @@ -30219,21 +30305,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -30577,7 +30689,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -30642,7 +30754,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -30662,6 +30774,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576) && isTypeAssignableToKind(indexType, 68 | 168 | 3072)) { if (isTypeAny(objectType)) { @@ -30672,7 +30790,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) { - var indexNode = accessNode.kind === 186 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 ? 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))) { @@ -30689,14 +30807,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 ? 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)); } @@ -30779,7 +30905,7 @@ var ts; if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188) && isGenericObjectType(objectType)) { if (objectType.flags & 3) { return objectType; } @@ -30896,7 +31022,7 @@ var ts; return true; } while (node) { - if (node.kind === 171) { + if (node.kind === 173) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -30993,7 +31119,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } 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); + var errorMessage = 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_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -31187,7 +31316,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239)) { if (!ts.hasModifier(container, 32) && (container.kind !== 155 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -31206,8 +31335,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119: - case 279: - case 280: + case 282: + case 283: return anyType; case 142: return unknownType; @@ -31229,16 +31358,16 @@ var ts; return neverType; case 135: return node.flags & 65536 ? anyType : nonPrimitiveType; - case 174: + case 176: case 99: return getTypeFromThisTypeNode(node); - case 178: + case 180: return getTypeFromLiteralTypeNode(node); case 162: return getTypeFromTypeReference(node); case 161: return booleanType; - case 207: + case 209: return getTypeFromTypeReference(node); case 165: return getTypeFromTypeQueryNode(node); @@ -31247,37 +31376,40 @@ var ts; case 168: return getTypeFromTupleTypeNode(node); case 169: + return getTypeFromOptionalTypeNode(node); + case 171: return getTypeFromUnionTypeNode(node); - case 170: + case 172: return getTypeFromIntersectionTypeNode(node); - case 281: + case 284: return getTypeFromJSDocNullableTypeNode(node); - case 283: + case 286: return addOptionality(getTypeFromTypeNode(node.type)); - case 173: - case 282: - case 278: - return getTypeFromTypeNode(node.type); + case 175: + case 170: case 285: + case 281: + return getTypeFromTypeNode(node.type); + case 288: return getTypeFromJSDocVariadicType(node); case 163: case 164: case 166: + case 290: case 287: - case 284: - case 288: + case 291: 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); + return getTypeFromTypeOperatorNode(node); + case 178: + return getTypeFromIndexedAccessTypeNode(node); case 179: + return getTypeFromMappedTypeNode(node); + case 173: + return getTypeFromConditionalTypeNode(node); + case 174: + return getTypeFromInferTypeNode(node); + case 181: return getTypeFromImportTypeNode(node); case 71: case 146: @@ -31405,7 +31537,7 @@ var ts; symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(symbol.flags, symbol.escapedName, 1 | (ts.getCheckFlags(symbol) & 1024)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 | ts.getCheckFlags(symbol) & (1024 | 4096 | 8192)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -31416,11 +31548,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -31475,14 +31602,14 @@ var ts; 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 === 213 ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174: + case 176: return !!tp.isThisType; case 71: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -31604,31 +31731,31 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192: - case 193: + case 194: + case 195: case 154: return isContextSensitiveFunctionLikeDeclaration(node); - case 184: + case 186: return ts.some(node.properties, isContextSensitive); - case 183: + case 185: return ts.some(node.elements, isContextSensitive); - case 201: + case 203: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200: + case 202: return node.operatorToken.kind === 54 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270: + case 273: return isContextSensitive(node.initializer); - case 191: + case 193: return isContextSensitive(node.expression); - case 263: + case 266: return ts.some(node.properties, isContextSensitive); - case 262: { + case 265: { var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265: { + case 268: { var expression = node.expression; return !!expression && isContextSensitive(expression); } @@ -31642,14 +31769,14 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193) { + if (node.kind !== 195) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; } } var body = node.body; - return body.kind === 213 ? false : isContextSensitive(body); + return body.kind === 216 ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -31700,8 +31827,192 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268: + case 193: + return elaborateError(node.expression, source, target); + case 202: + switch (node.operatorToken.kind) { + case 58: + case 26: + return elaborateError(node.right, source, target); + } + break; + case 186: + return elaborateObjectLiteral(node, source, target); + case 185: + return elaborateArrayLiteral(node, source, target); + case 266: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + function elaborateElementwise(iterator, source, target) { + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + var resultObj = {}; + var specificSource = next ? checkExpressionForMutableLocation(next, 0, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, undefined, resultObj); + if (result && specificSource !== sourcePropType) { + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168) && getIndexInfoOfType(target, 1) || + getIndexInfoOfType(target, 0) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3, 3]; + return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3, 1]; + case 4: return [2]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3, 4]; + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3, 3]; + nameType = getLiteralType(i); + return [4, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3, 1]; + case 4: return [2]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240); + if (!type || (type.flags & 32768)) { + return [3, 7]; + } + _b = prop.kind; + switch (_b) { + case 157: return [3, 2]; + case 156: return [3, 2]; + case 154: return [3, 2]; + case 274: return [3, 2]; + case 273: return [3, 4]; + } + return [3, 6]; + case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3, 7]; + case 4: return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3, 1]; + case 8: return [2]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } function checkTypeComparableTo(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); @@ -31713,13 +32024,20 @@ var ts; if (source === target) { return -1; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0; + } var kind = target.declaration ? target.declaration.kind : 0; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 && kind !== 153 && kind !== 155; @@ -31739,14 +32057,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && @@ -31756,7 +32071,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0; } @@ -31826,27 +32141,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -31867,11 +32161,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 && errorReporter)) { + return relation === 1; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) { - enumRelation.set(id, false); + enumRelation.set(id, 3); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -31882,13 +32176,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64)); + enumRelation.set(id, 3); + } + else { + enumRelation.set(id, 2); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -31966,7 +32263,7 @@ var ts; function isIgnoredJsxProperty(source, sourceProp, targetMemberType) { return ts.getObjectFlags(source) & 4096 && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); } - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -31994,12 +32291,16 @@ var ts; if (links.originatingImport && !ts.isImportCall(links.originatingImport)) { var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, undefined); if (helpfulRetry) { - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); } return result !== 0; function reportError(message, arg0, arg1, arg2) { @@ -32073,6 +32374,13 @@ var ts; if (target.flags & 2097152) { target = getSimplifiedType(target); } + if (target.flags & 262144 && source.flags & 131072 && + target.types.length <= 3 && maybeTypeOfKind(target, 24576)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576); + if (!(nullStrippedTarget.flags & (262144 | 32768))) { + target = nullStrippedTarget; + } + } if (source === target) return -1; if (relation === identityRelation) { @@ -32286,11 +32594,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], true); } return 0; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 262144) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4) { + return source.target === target.target; + } + if (overlapObjFlags & 16) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } function findMatchingDiscriminantType(source, target) { var match; var sourceProperties = getPropertiesOfObjectType(source); @@ -32405,7 +32731,6 @@ var ts; var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { - relation.set(id, 3); } else { return related === 1 ? -1 : 0; @@ -32646,7 +32971,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -32669,6 +32994,33 @@ var ts; } } var result = -1; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -33110,15 +33462,21 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -33149,10 +33507,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0; @@ -33171,9 +33529,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -33217,7 +33572,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 | 32768)); @@ -33260,6 +33620,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -33498,7 +33864,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200: + case 202: case 152: case 151: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -33508,23 +33874,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182: + case 184: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234: + case 237: case 154: case 153: case 156: case 157: - case 192: - case 193: + case 194: + case 195: 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 177: + case 179: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -33540,24 +33906,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -33684,8 +34048,12 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, false) && !!getUnmatchedProperty(target, source, false); } function getTypeFromInference(inference) { @@ -33926,12 +34294,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -34034,14 +34423,12 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { inferredType = getCovariantInference(inference, context, signature); - if (inferredType.flags & 32768 && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - inferredType = getContravariantInference(inference); } else if (context.flags & 2) { inferredType = silentNeverType; @@ -34099,13 +34486,13 @@ var ts; if (node.kind === 99) { return "0"; } - if (node.kind === 185) { + if (node.kind === 187) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182) { + if (node.kind === 184) { var container = node.parent.parent; - var key = container.kind === 182 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -34114,7 +34501,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180) { + if (parent.kind === 182) { var name = element.propertyName || element.name; switch (name.kind) { case 71: @@ -34136,26 +34523,26 @@ var ts; switch (source.kind) { case 71: return target.kind === 71 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 || target.kind === 182) && + (target.kind === 235 || target.kind === 184) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99: return target.kind === 99; case 97: return target.kind === 97; - case 185: - return target.kind === 185 && + case 187: + return target.kind === 187 && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182: - if (target.kind !== 185) + case 184: + if (target.kind !== 187) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232) { + if (source.parent.parent.kind === 235) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -34163,7 +34550,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185) { + while (source.kind === 187) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -34172,7 +34559,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 185 && + return target.kind === 187 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -34180,7 +34567,7 @@ var ts; if (expr.kind === 71) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185) { + if (expr.kind === 187) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -34224,7 +34611,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 && + if (callExpression.expression.kind === 187 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -34345,7 +34732,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, undefined, false, false) || errorType; } @@ -34353,15 +34740,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 && parent.parent.left === parent || - parent.parent.kind === 222 && parent.parent.initializer === parent; + return parent.parent.kind === 202 && parent.parent.left === parent || + parent.parent.kind === 225 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -34378,21 +34765,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221: + case 224: return stringType; - case 222: + case 225: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200: + case 202: return getAssignedTypeOfBinaryExpression(parent); - case 194: + case 196: return undefinedType; - case 183: + case 185: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204: + case 206: return getAssignedTypeOfSpreadExpression(parent); - case 270: + case 273: return getAssignedTypeOfPropertyAssignment(parent); - case 271: + case 274: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -34400,7 +34787,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 ? + var type = pattern.kind === 182 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -34415,35 +34802,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221) { + if (node.parent.parent.kind === 224) { return stringType; } - if (node.parent.parent.kind === 222) { + if (node.parent.parent.kind === 225) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 ? + return node.kind === 235 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 || node.kind === 182 ? + return node.kind === 235 || node.kind === 184 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 && node.initializer && + return node.kind === 235 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 && node.parent.kind === 200 && + node.kind !== 184 && node.parent.kind === 202 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191: + case 193: return getReferenceCandidate(node.expression); - case 200: + case 202: switch (node.operatorToken.kind) { case 58: return getReferenceCandidate(node.left); @@ -34455,13 +34842,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 191 || - parent.kind === 200 && parent.operatorToken.kind === 58 && parent.left === node || - parent.kind === 200 && parent.operatorToken.kind === 26 && parent.right === node ? + return parent.kind === 193 || + parent.kind === 202 && parent.operatorToken.kind === 58 && parent.left === node || + parent.kind === 202 && parent.operatorToken.kind === 26 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266) { + if (clause.kind === 269) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -34608,11 +34995,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 185 && (parent.name.escapedText === "length" || - parent.parent.kind === 187 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 186 && + var isLengthPushOrUnshift = parent.kind === 187 && (parent.name.escapedText === "length" || + parent.parent.kind === 189 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 && parent.expression === root && - parent.parent.kind === 200 && + parent.parent.kind === 202 && parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -34656,7 +35043,7 @@ var ts; 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 === 209 && getTypeWithFacts(resultType, 524288).flags & 32768) { + if (reference.parent && reference.parent.kind === 211 && getTypeWithFacts(resultType, 524288).flags & 32768) { return declaredType; } return resultType; @@ -34718,7 +35105,7 @@ var ts; } else if (flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 185 && reference.kind !== 99) { + if (container && container !== flowContainer && reference.kind !== 187 && reference.kind !== 99) { flow = container.flowNode; continue; } @@ -34763,7 +35150,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 ? + var expr = node.kind === 189 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -34771,7 +35158,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 187) { + if (node.kind === 189) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -34895,7 +35282,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 && + return expr.kind === 187 && computedType.flags & 262144 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -34946,10 +35333,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 === 195 && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -35143,7 +35530,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 || invokedExpression.kind === 185) { + if (invokedExpression.kind === 188 || invokedExpression.kind === 187) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -35161,15 +35548,15 @@ var ts; case 71: case 99: case 97: - case 185: - return narrowTypeByTruthiness(type, expr, assumeTrue); case 187: + return narrowTypeByTruthiness(type, expr, assumeTrue); + case 189: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191: + case 193: return narrowType(type, expr.expression, assumeTrue); - case 200: + case 202: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198: + case 200: if (expr.operator === 51) { return narrowType(type, expr.operand, !assumeTrue); } @@ -35196,8 +35583,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 || - node.kind === 274 || + node.kind === 243 || + node.kind === 277 || node.kind === 152; }); } @@ -35241,10 +35628,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 185 || - parent.kind === 187 && parent.expression === node || - parent.kind === 186 && parent.expression === node || - parent.kind === 182 && parent.name === node && !!parent.initializer; + return parent.kind === 187 || + parent.kind === 189 && parent.expression === node || + parent.kind === 188 && parent.expression === node || + parent.kind === 184 && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576); @@ -35268,7 +35655,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 193) { + if (container.kind === 195) { 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)) { @@ -35284,7 +35671,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 235 + if (declaration.kind === 238 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -35296,9 +35683,9 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205) { + else if (declaration.kind === 207) { var container = ts.getThisContainer(node, false); - while (container.kind !== 274) { + while (container.kind !== 277) { if (container.parent === declaration) { if (container.kind === 152 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 8388608; @@ -35343,17 +35730,17 @@ var ts; 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 === 192 || - flowContainer.kind === 193 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 || + flowContainer.kind === 195 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } - var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3) !== 0 || - isInTypeQuery(node) || node.parent.kind === 252) || - node.parent.kind === 209 || - declaration.kind === 232 && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 255) || + node.parent.kind === 211 || + declaration.kind === 235 && declaration.exclamationToken || declaration.flags & 4194304; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -35380,7 +35767,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 269) { + symbol.valueDeclaration.parent.kind === 272) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -35398,8 +35785,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 220 && - ts.getAncestor(symbol.valueDeclaration, 233).parent === container && + if (container.kind === 223 && + ts.getAncestor(symbol.valueDeclaration, 236).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -35411,14 +35798,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 191) { + while (current.parent.kind === 193) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 || current.parent.kind === 199)) { + else if ((current.parent.kind === 200 || current.parent.kind === 201)) { var expr = current.parent; isAssigned = expr.operator === 43 || expr.operator === 44; } @@ -35462,7 +35849,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { var superCall = getSuperCallInConstructor(container); if (!superCall || superCall.end > node.pos) { @@ -35476,15 +35863,15 @@ var ts; 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 === 193) { + if (container.kind === 195) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 239: + case 242: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 238: + case 241: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 155: @@ -35515,8 +35902,8 @@ var ts; if (container === void 0) { container = ts.getThisContainer(node, false); } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 192 && - container.parent.kind === 200 && + if (container.kind === 194 && + container.parent.kind === 202 && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -35546,7 +35933,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284) { + if (jsdocType && jsdocType.kind === 287) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -35563,11 +35950,11 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 193) { + while (container && container.kind === 195) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -35582,7 +35969,7 @@ var ts; 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 === 184)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -35611,7 +35998,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184) { + if (container.parent.kind === 186) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -35621,7 +36008,7 @@ var ts; } } var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -35645,7 +36032,7 @@ var ts; return container.kind === 155; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 184) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186) { if (ts.hasModifier(container, 32)) { return container.kind === 154 || container.kind === 153 || @@ -35669,8 +36056,8 @@ var ts; function getContainingObjectLiteral(func) { 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 : + func.kind === 157) && func.parent.kind === 186 ? func.parent : + func.kind === 194 && func.parent.kind === 273 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -35682,7 +36069,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193) { + if (func.kind === 195) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -35706,7 +36093,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270) { + if (literal.parent.kind !== 273) { break; } literal = literal.parent.parent; @@ -35715,9 +36102,9 @@ var ts; return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } var parent = func.parent; - if (parent.kind === 200 && parent.operatorToken.kind === 58) { + if (parent.kind === 202 && parent.operatorToken.kind === 58) { var target = parent.left; - if (target.kind === 185 || target.kind === 186) { + if (target.kind === 187 || target.kind === 188) { var expression = target.expression; if (inJs && ts.isIdentifier(expression)) { var sourceFile = ts.getSourceFileOfNode(parent); @@ -35738,27 +36125,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); @@ -35767,10 +36151,8 @@ var ts; if (indexOfParameter < len) { return getTypeAtPosition(contextualSignature, indexOfParameter); } - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -35793,7 +36175,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182) { + if (parentDeclaration.kind !== 184) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -35868,7 +36250,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189) { + if (template.parent.kind === 191) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -35909,8 +36291,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, true); } function getIndexTypeOfContextualType(type, kind) { @@ -35931,8 +36324,8 @@ var ts; var type = getApparentTypeOfContextualType(objectLiteral); if (type) { if (!hasNonBindableDynamicName(element)) { - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -35986,8 +36379,8 @@ var ts; case 95: case 71: return true; - case 185: - case 191: + case 187: + case 193: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -36003,14 +36396,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270) + if (prop.kind !== 273) continue; 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); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; @@ -36033,51 +36426,51 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232: + case 235: case 149: case 152: case 151: - case 182: + case 184: return getContextualTypeForInitializerExpression(node); - case 193: - case 225: + case 195: + case 228: return getContextualTypeForReturnExpression(node); - case 203: + case 205: return getContextualTypeForYieldOperand(parent); - case 187: - case 188: - return getContextualTypeForArgument(parent, node); + case 189: case 190: - case 208: + return getContextualTypeForArgument(parent, node); + case 192: + case 210: return getTypeFromTypeNode(parent.type); - case 200: + case 202: return getContextualTypeForBinaryOperand(node); - case 270: - case 271: + case 273: + case 274: return getContextualTypeForObjectLiteralElement(parent); - case 272: + case 275: return getApparentTypeOfContextualType(parent.parent); - case 183: { + case 185: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201: + case 203: return getContextualTypeForConditionalOperand(node); - case 211: - ts.Debug.assert(parent.parent.kind === 202); + case 214: + ts.Debug.assert(parent.parent.kind === 204); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191: { + case 193: { var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 265: + case 268: return getContextualTypeForJsxExpression(parent); - case 262: - case 264: + case 265: + case 267: return getContextualTypeForJsxAttribute(parent); - case 257: - case 256: + case 260: + case 259: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -36142,6 +36535,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -36152,8 +36546,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) : forcedLookupLocation === "" @@ -36165,7 +36575,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { return attributesType; } else { @@ -36205,11 +36616,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 || node.kind === 193; + return node.kind === 194 || node.kind === 195; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -36271,18 +36681,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false, false); } function hasDefaultValue(node) { - return (node.kind === 182 && !!node.initializer) || - (node.kind === 200 && node.operatorToken.kind === 58); + return (node.kind === 184 && !!node.initializer) || + (node.kind === 202 && node.operatorToken.kind === 58); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204) { + if (inDestructuringPattern && e.kind === 206) { var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || getIteratedTypeOrElementType(restArrayType, undefined, false, false, false); @@ -36295,38 +36706,44 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204; + if (index < elementCount - 1 && e.kind === 206) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206; + var minLength = elementCount - (hasRestElement ? 1 : 0); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 181 || pattern.kind === 183)) { + if (!hasRestElement && pattern && (pattern.kind === 183 || pattern.kind === 185)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - if (patternElement.kind !== 206) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + else if (i < patternElements.length - 1 || !(e.kind === 184 && e.dotDotDotToken || e.kind === 206)) { + if (e.kind !== 208) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -36385,7 +36802,7 @@ var ts; var propagatedFlags = 33554432; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 || contextualType.pattern.kind === 184); + (contextualType.pattern.kind === 182 || contextualType.pattern.kind === 186); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -36399,11 +36816,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 || - memberDecl.kind === 271 || + if (memberDecl.kind === 273 || + memberDecl.kind === 274 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -36422,8 +36839,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 270 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -36446,7 +36863,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272) { + else if (memberDecl.kind === 275) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -36533,18 +36950,24 @@ var ts; type.flags & 131072 && !isGenericMappedType(type) || type.flags & 786432 && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + function checkJsxElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0); if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); } else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -36560,15 +36983,7 @@ var ts; return !ts.stringContains(name, "-"); } function isJsxIntrinsicIdentifier(tagName) { - switch (tagName.kind) { - case 185: - case 99: - return false; - case 71: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -36602,7 +37017,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264); + ts.Debug.assert(attributeDecl.kind === 267); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, 4096); attributesTable = ts.createSymbolTable(); @@ -36624,7 +37039,7 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, 4096); } } - var parent = openingLikeElement.parent.kind === 255 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -36758,12 +37173,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } return getGlobalSymbol(JsxNames.JSX, 1920, undefined); @@ -36785,6 +37212,9 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928); + } function getJsxElementPropertiesName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace); } @@ -37060,7 +37490,7 @@ var ts; var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : getCustomJsxElementAttributesType(openingLikeElement, false); - var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { for (var _i = 0, _a = openingLikeElement.attributes.properties; _i < _a.length; _i++) { @@ -37077,28 +37507,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -37131,9 +37540,9 @@ var ts; } function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 || node.kind === 232 ? + var errorNode = node.kind === 187 || node.kind === 235 ? node.name : - node.kind === 179 ? + node.kind === 181 ? node : node.right; if (ts.getCheckFlags(prop) & 256) { @@ -37275,7 +37684,7 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - if (node.kind !== 185 || + if (node.kind !== 187 || assignmentKind === 1 || prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 262144)) { return propType; @@ -37302,16 +37711,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 && + else if (valueDeclaration.kind === 238 && node.parent.kind !== 162 && !(valueDeclaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -37319,7 +37733,7 @@ var ts; switch (node.kind) { case 152: return true; - case 270: + case 273: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -37370,13 +37784,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -37416,16 +37836,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185: + case 187: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179: + case 181: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -37455,7 +37875,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233) { + if (initializer.kind === 236) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -37477,7 +37897,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 && + if (node.kind === 224 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -37495,7 +37915,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 && node.parent.expression === node) { + if (node.parent.kind === 190 && 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); @@ -37554,7 +37974,7 @@ var ts; if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189) { + if (node.kind === 191) { checkExpression(node.template); } else if (node.kind !== 150) { @@ -37605,14 +38025,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 || arg.kind === 213 && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -37623,10 +38040,10 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { return true; } - if (node.kind === 189) { + if (node.kind === 191) { argCount = args.length; typeArguments = node.typeArguments; - if (node.template.kind === 202) { + if (node.template.kind === 204) { var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } @@ -37642,8 +38059,8 @@ var ts; } else { if (!node.arguments) { - ts.Debug.assert(node.kind === 188); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; callIsIncomplete = node.arguments.end === node.end; @@ -37654,13 +38071,12 @@ var ts; return false; } if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -37681,8 +38097,9 @@ var ts; } function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8); @@ -37711,7 +38128,7 @@ var ts; var instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 8); @@ -37723,10 +38140,12 @@ var ts; var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; inferTypes(context.inferences, thisArgumentType, thisType); } - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 206) { + if (arg === undefined || arg.kind !== 208) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -37736,6 +38155,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } if (excludeArgument) { for (var i = 0; i < argCount; i++) { if (excludeArgument[i] === false) { @@ -37747,6 +38170,33 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + return arg.kind === 213 ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 | 1048576); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -37791,7 +38241,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188) { + if (thisType && thisType !== voidType && node.kind !== 190) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -37802,34 +38252,42 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 206) { - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208) { + if (i === restIndex && (restType.flags & 65536 || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } return true; } function getThisArgumentOfCall(node) { - if (node.kind === 187) { + if (node.kind === 189) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 || callee.kind === 186) { + if (callee.kind === 187 || callee.kind === 188) { return callee.expression; } } } function getEffectiveCallArguments(node) { - if (node.kind === 189) { + if (node.kind === 191) { var template = node.template; var args_4 = [undefined]; - if (template.kind === 202) { + if (template.kind === 204) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -37843,14 +38301,32 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150) { switch (node.parent.kind) { - case 235: - case 205: + case 238: + case 207: return 1; case 152: return 2; @@ -37872,7 +38348,7 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 235) { + if (node.kind === 238) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -37893,7 +38369,7 @@ var ts; return errorType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 235) { + if (node.kind === 238) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -37932,7 +38408,7 @@ var ts; return errorType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 235) { + if (node.kind === 238) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -37969,14 +38445,14 @@ var ts; if (node.kind === 150) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189) { + else if (argIndex === 0 && node.kind === 191) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { if (node.kind === 150 || - (argIndex === 0 && node.kind === 189)) { + (argIndex === 0 && node.kind === 191)) { return undefined; } return args[argIndex]; @@ -37985,7 +38461,7 @@ var ts; if (node.kind === 150) { return node.expression; } - else if (argIndex === 0 && node.kind === 189) { + else if (argIndex === 0 && node.kind === 191) { return node.template; } else { @@ -38004,7 +38480,7 @@ 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 === 189; + var isTaggedTemplate = node.kind === 191; var isDecorator = node.kind === 150; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -38038,7 +38514,7 @@ var ts; var candidateForArgumentError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 187 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -38065,10 +38541,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -38175,11 +38651,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -38193,7 +38670,7 @@ var ts; return anySignature; } if (superType !== errorType) { - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -38328,8 +38805,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -38351,8 +38827,8 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235: - case 205: + case 238: + case 207: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -38410,16 +38886,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187: - return resolveCallExpression(node, candidatesOutArray); - case 188: - return resolveNewExpression(node, candidatesOutArray); case 189: + return resolveCallExpression(node, candidatesOutArray); + case 190: + return resolveNewExpression(node, candidatesOutArray); + case 191: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150: return resolveDecorator(node, candidatesOutArray); - case 257: - case 256: + case 260: + case 259: var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray); @@ -38474,7 +38950,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -38488,7 +38965,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185) { + while (parent && parent.kind === 187) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58) { @@ -38515,7 +38992,7 @@ var ts; if (node.expression.kind === 97) { return voidType; } - if (node.kind === 188) { + if (node.kind === 190) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 && @@ -38632,9 +39109,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 234 + ? 237 : resolvedRequire.flags & 3 - ? 232 + ? 235 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -38711,10 +39188,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -38753,10 +39327,10 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -38816,7 +39390,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213) { + if (func.body.kind !== 216) { 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); @@ -38895,7 +39469,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member @@ -38919,7 +39493,7 @@ var ts; if (!(func.flags & 128)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -38956,11 +39530,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192: - case 193: + case 194: + case 195: return true; case 154: - return func.parent.kind === 184; + return func.parent.kind === 186; default: return false; } @@ -38972,7 +39546,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 3 | 4096)) { return; } - if (func.kind === 153 || ts.nodeIsMissing(func.body) || func.body.kind !== 213 || !functionHasImplicitReturn(func)) { + if (func.kind === 153 || ts.nodeIsMissing(func.body) || func.body.kind !== 216 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -39004,7 +39578,7 @@ var ts; return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192) { + if (!hasGrammarError && node.kind === 194) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -39055,7 +39629,7 @@ var ts; if (!returnTypeNode) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213) { + if (node.body.kind === 216) { checkSourceElement(node.body); } else { @@ -39063,10 +39637,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3) === 2) { var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -39089,7 +39663,7 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 185 || expr.kind === 186) && + (expr.kind === 187 || expr.kind === 188) && expr.expression.kind === 99) { var func = ts.getContainingFunction(expr); if (!(func && func.kind === 155)) { @@ -39102,13 +39676,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 || expr.kind === 186) { + if (expr.kind === 187 || expr.kind === 188) { 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 === 246; + return !!declaration && declaration.kind === 249; } } } @@ -39116,7 +39690,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipOuterExpressions(expr, 2 | 1); - if (node.kind !== 71 && node.kind !== 185 && node.kind !== 186) { + if (node.kind !== 71 && node.kind !== 187 && node.kind !== 188) { error(expr, invalidReferenceMessage); return false; } @@ -39125,7 +39699,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 && expr.kind !== 186) { + if (expr.kind !== 187 && expr.kind !== 188) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -39286,7 +39860,7 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 270 || property.kind === 271) { + if (property.kind === 273 || property.kind === 274) { var name = property.name; if (name.kind === 147) { checkComputedPropertyName(name); @@ -39301,7 +39875,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 271) { + if (property.kind === 274) { return checkDestructuringAssignment(property, type); } else { @@ -39312,7 +39886,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 === 272) { + else if (property.kind === 275) { if (languageVersion < 6) { checkExternalEmitHelpers(property, 4); } @@ -39344,25 +39918,21 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206) { - if (element.kind !== 204) { + if (element.kind !== 208) { + if (element.kind !== 206) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -39371,12 +39941,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 && restExpression.operatorToken.kind === 58) { + if (restExpression.kind === 202 && restExpression.operatorToken.kind === 58) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -39385,7 +39958,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271) { + if (exprOrAssignment.kind === 274) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -39399,25 +39972,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 && target.operatorToken.kind === 58) { + if (target.kind === 202 && target.operatorToken.kind === 58) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184) { + if (target.kind === 186) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183) { + if (target.kind === 185) { 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 === 272 ? + var error = target.parent.kind === 275 ? 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)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -39427,35 +40000,35 @@ var ts; case 71: case 9: case 12: - case 189: - case 202: + case 191: + case 204: case 13: case 8: case 101: case 86: case 95: case 140: - case 192: - case 205: - case 193: - case 183: - case 184: + case 194: + case 207: case 195: - case 209: - case 256: - case 255: + case 185: + case 186: + case 197: + case 211: + case 259: + case 258: return true; - case 201: + case 203: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200: + case 202: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198: - case 199: + case 200: + case 201: switch (node.operator) { case 51: case 37: @@ -39464,9 +40037,9 @@ var ts; return true; } return false; - case 196: - case 190: - case 208: + case 198: + case 192: + case 210: default: return false; } @@ -39482,7 +40055,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 && (left.kind === 184 || left.kind === 183)) { + if (operator === 58 && (left.kind === 186 || left.kind === 185)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -39664,7 +40237,7 @@ var ts; if (produceDiagnostics && ts.isAssignmentOperator(operator)) { if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { - checkTypeAssignableTo(valueType, leftType, left, undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -39685,7 +40258,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34: + case 32: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35: + case 33: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -39734,7 +40323,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } return anyType; } @@ -39753,7 +40342,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263) { + if (node.kind === 266) { return node.parent.parent; } return node; @@ -39786,7 +40375,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 || node.kind === 208; + return node.kind === 192 || node.kind === 210; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -39868,7 +40457,7 @@ var ts; return type; } function getTypeOfExpression(node, cache) { - if (node.kind === 187 && node.expression.kind !== 97 && !ts.isRequireCall(node, true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 && node.expression.kind !== 97 && !ts.isRequireCall(node, true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -39897,8 +40486,8 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 185 && node.parent.expression === node) || - (node.parent.kind === 186 && node.parent.expression === node) || + var ok = (node.parent.kind === 187 && node.parent.expression === node) || + (node.parent.kind === 188 && node.parent.expression === node) || ((node.kind === 71 || node.kind === 146) && isInRightSideOfImportOrExportAssignment(node) || (node.parent.kind === 165 && node.parent.exprName === node)); if (!ok) { @@ -39934,73 +40523,75 @@ var ts; return trueType; case 86: return falseType; - case 202: + case 204: return checkTemplateExpression(node); case 12: return globalRegExpType; - case 183: - return checkArrayLiteral(node, checkMode); - case 184: - return checkObjectLiteral(node, checkMode); case 185: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, checkMode); case 186: - return checkIndexedAccess(node); + return checkObjectLiteral(node, checkMode); case 187: + return checkPropertyAccessExpression(node); + case 188: + return checkIndexedAccess(node); + case 189: if (node.expression.kind === 91) { return checkImportCallExpression(node); } - case 188: - return checkCallExpression(node); - case 189: - 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); + return checkCallExpression(node); + case 191: + return checkTaggedTemplateExpression(node); + case 193: + return checkParenthesizedExpression(node, checkMode); + case 207: + return checkClassExpression(node); case 194: - return checkDeleteExpression(node); - case 196: - return checkVoidExpression(node); + case 195: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); case 197: - return checkAwaitExpression(node); + return checkTypeOfExpression(node); + case 192: + case 210: + return checkAssertion(node); + case 211: + return checkNonNullAssertion(node); + case 212: + return checkMetaProperty(node); + case 196: + return checkDeleteExpression(node); case 198: - return checkPrefixUnaryExpression(node); + return checkVoidExpression(node); case 199: - return checkPostfixUnaryExpression(node); + return checkAwaitExpression(node); case 200: - return checkBinaryExpression(node, checkMode); + return checkPrefixUnaryExpression(node); case 201: - return checkConditionalExpression(node, checkMode); - case 204: - return checkSpreadExpression(node, checkMode); - case 206: - return undefinedWideningType; + return checkPostfixUnaryExpression(node); + case 202: + return checkBinaryExpression(node, checkMode); case 203: + return checkConditionalExpression(node, checkMode); + case 206: + return checkSpreadExpression(node, checkMode); + case 208: + return undefinedWideningType; + case 205: return checkYieldExpression(node); - case 265: + case 213: + return node.type; + case 268: return checkJsxExpression(node, checkMode); - case 255: + case 258: return checkJsxElement(node, checkMode); - case 256: - return checkJsxSelfClosingElement(node, checkMode); case 259: + return checkJsxSelfClosingElement(node, checkMode); + case 262: return checkJsxFragment(node, checkMode); - case 263: + case 266: return checkJsxAttributes(node, checkMode); - case 257: + case 260: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -40027,6 +40618,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); @@ -40047,7 +40641,7 @@ var ts; error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -40105,10 +40699,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193: + case 195: case 158: - case 234: - case 192: + case 237: + case 194: case 163: case 154: case 153: @@ -40129,7 +40723,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 === 181 || name.kind === 180) { + else if (name.kind === 183 || name.kind === 182) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -40140,7 +40734,7 @@ var ts; if (node.kind === 160) { checkGrammarIndexSignature(node); } - else if (node.kind === 163 || node.kind === 234 || node.kind === 164 || + else if (node.kind === 163 || node.kind === 237 || node.kind === 164 || node.kind === 158 || node.kind === 155 || node.kind === 159) { checkGrammarFunctionLikeDeclaration(node); @@ -40194,7 +40788,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 && node.kind !== 284) { + if (node.kind !== 160 && node.kind !== 287) { registerForUnusedIdentifiersCheck(node); } } @@ -40305,7 +40899,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236) { + if (node.kind === 239) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -40376,7 +40970,7 @@ var ts; !!n.initializer; } var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -40391,7 +40985,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 === 216 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -40533,10 +41127,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -40549,7 +41161,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 186 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -40584,7 +41196,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -40598,9 +41210,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 236 && - n.parent.kind !== 235 && - n.parent.kind !== 205 && + if (n.parent.kind !== 239 && + n.parent.kind !== 238 && + n.parent.kind !== 207 && n.flags & 4194304) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; @@ -40713,11 +41325,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304; - var inAmbientContextOrInterface = node.parent.kind === 236 || node.parent.kind === 166 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 || node.parent.kind === 166 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 234 || node.kind === 154 || node.kind === 153 || node.kind === 155) { + if (node.kind === 237 || node.kind === 154 || node.kind === 153 || node.kind === 155) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -40830,36 +41442,36 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236: - case 237: - case 298: - case 292: - return 2; case 239: + case 240: + case 301: + case 295: + return 2; + case 242: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 235: case 238: + case 241: return 2 | 1; - case 274: + case 277: return 2 | 1 | 4; - case 249: + case 252: if (!ts.isEntityNameExpression(d.expression)) { return 1; } d = d.expression; - case 243: case 246: - case 245: + case 249: + case 248: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 232: - case 182: - case 234: - case 248: + case 235: + case 184: + case 237: + case 251: return 1; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -41015,7 +41627,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235: + case 238: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -41065,12 +41677,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170: - case 169: + case 172: + case 171: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173) { + while (typeNode.kind === 175) { typeNode = typeNode.type; } if (typeNode.kind === 131) { @@ -41095,7 +41707,7 @@ var ts; } } return commonEntityName; - case 173: + case 175: return getEntityNameForDecoratorMetadata(node.type); case 162: return node.typeName; @@ -41124,7 +41736,7 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 235: + case 238: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -41209,7 +41821,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -41221,7 +41833,7 @@ var ts; switch (node.kind) { case 71: return node; - case 185: + case 187: return node.name; default: return undefined; @@ -41280,27 +41892,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235: - case 205: + case 238: + case 207: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236: + case 239: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274: - case 239: - case 213: - case 241: - case 220: - case 221: - case 222: + case 277: + case 242: + case 216: + case 244: + case 223: + case 224: + case 225: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155: - case 192: - case 234: - case 193: + case 194: + case 237: + case 195: case 154: case 156: case 157: @@ -41314,7 +41926,7 @@ var ts; case 159: case 163: case 164: - case 237: + case 240: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -41327,10 +41939,7 @@ var ts; 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.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -41359,7 +41968,7 @@ var ts; } break; case 160: - case 212: + case 215: break; default: ts.Debug.fail(); @@ -41372,7 +41981,7 @@ var ts; if (!(node.flags & 4194304) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -41404,7 +42013,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -41421,9 +42030,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -41438,7 +42047,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0, unuseds.length === 1 @@ -41456,7 +42065,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 && bindingPattern.parent.parent.kind === 233) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 && bindingPattern.parent.parent.kind === 236) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -41477,7 +42086,7 @@ var ts; 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)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -41491,21 +42100,21 @@ var ts; switch (name.kind) { case 71: return ts.idText(name); - case 181: - case 180: + case 183: + case 182: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 || node.kind === 248 || node.kind === 246; + return node.kind === 248 || node.kind === 251 || node.kind === 249; } function importClauseFromImported(decl) { - return decl.kind === 245 ? decl : decl.kind === 246 ? decl.parent : decl.parent.parent; + return decl.kind === 248 ? decl : decl.kind === 249 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 213) { + if (node.kind === 216) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -41592,7 +42201,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 274 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 && 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)); } } @@ -41604,7 +42213,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 274 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 277 && 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)); } } @@ -41612,7 +42221,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 232 && !node.initializer) { + if (node.kind === 235 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -41624,15 +42233,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233); - var container = varDeclList.parent.kind === 214 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236); + var container = varDeclList.parent.kind === 217 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 213 && ts.isFunctionLike(container.parent) || - container.kind === 240 || - container.kind === 239 || - container.kind === 274); + (container.kind === 216 && ts.isFunctionLike(container.parent) || + container.kind === 243 || + container.kind === 242 || + container.kind === 277); 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); @@ -41651,7 +42260,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 185) { + if (n.kind === 187) { return visit(n.expression); } else if (n.kind === 71) { @@ -41666,7 +42275,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 || - symbol.valueDeclaration.kind === 182) { + symbol.valueDeclaration.kind === 184) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -41707,8 +42316,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182) { - if (node.parent.kind === 180 && languageVersion < 6) { + if (node.kind === 184) { + if (node.parent.kind === 182 && languageVersion < 6) { checkExternalEmitHelpers(node, 4); } if (node.propertyName && node.propertyName.kind === 147) { @@ -41726,7 +42335,7 @@ var ts; } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); @@ -41736,13 +42345,13 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 221) { + if (node.initializer && node.parent.parent.kind !== 224) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -41757,8 +42366,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined); checkParameterInitializer(node); } } @@ -41771,7 +42380,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -41780,7 +42389,7 @@ var ts; } if (node.kind !== 152 && node.kind !== 151) { checkExportsOnMergedDeclarations(node); - if (node.kind === 232 || node.kind === 182) { + if (node.kind === 235 || node.kind === 184) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -41795,8 +42404,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 && right.kind === 232) || - (left.kind === 232 && right.kind === 149)) { + if ((left.kind === 149 && right.kind === 235) || + (left.kind === 235 && right.kind === 149)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -41831,7 +42440,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215) { + if (node.thenStatement.kind === 218) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -41848,12 +42457,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233) { + if (node.initializer && node.initializer.kind === 236) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233) { + if (node.initializer.kind === 236) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -41880,20 +42489,20 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 233) { + if (node.initializer.kind === 236) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); - if (varExpr.kind === 183 || varExpr.kind === 184) { + if (varExpr.kind === 185 || varExpr.kind === 186) { checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -41905,7 +42514,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 233) { + if (node.initializer.kind === 236) { 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); @@ -41915,7 +42524,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 183 || varExpr.kind === 184) { + if (varExpr.kind === 185 || varExpr.kind === 186) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -42167,7 +42776,7 @@ var ts; } } else if (func.kind === 155) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -42180,7 +42789,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -42209,7 +42818,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 267 && !hasDuplicateDefaultClause) { + if (clause.kind === 270 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -42221,7 +42830,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266) { + if (produceDiagnostics && clause.kind === 269) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -42245,7 +42854,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -42334,13 +42943,14 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; - if (indexKind === 1 && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); + if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 || - ts.getNameOfDeclaration(propDeclaration).kind === 147 || + if (propDeclaration && name && + (propDeclaration.kind === 202 || + name.kind === 147 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -42492,7 +43102,7 @@ var ts; if (!(node.flags & 4194304)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2) { checkExternalEmitHelpers(baseTypeNode.parent, 1); @@ -42504,6 +43114,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -42565,7 +43179,7 @@ var ts; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -42583,7 +43197,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag); @@ -42606,7 +43220,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 || d.kind === 236; + return d.kind === 238 || d.kind === 239; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -42624,7 +43238,7 @@ var ts; if (derived === base) { var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { - if (derivedClassDecl.kind === 205) { + if (derivedClassDecl.kind === 207) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -42733,7 +43347,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -42792,7 +43406,7 @@ var ts; if (member.initializer) { return computeConstantValue(member); } - if (member.parent.flags & 4194304 && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 && !ts.isEnumConst(member.parent)) { return undefined; } if (autoValue !== undefined) { @@ -42803,7 +43417,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -42829,7 +43443,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198: + case 200: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -42839,7 +43453,7 @@ var ts; } } break; - case 200: + case 202: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -42867,7 +43481,7 @@ var ts; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 191: + case 193: return evaluate(expr.expression); case 71: var identifier = expr; @@ -42875,14 +43489,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186: - case 185: + case 188: + case 187: 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 === 185) { + if (ex.kind === 187) { name = ex.name.escapedText; } else { @@ -42914,8 +43528,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 || - node.kind === 185 && isConstantMemberAccess(node.expression) || - node.kind === 186 && isConstantMemberAccess(node.expression) && + node.kind === 187 && isConstantMemberAccess(node.expression) || + node.kind === 188 && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9; } function checkEnumDeclaration(node) { @@ -42928,7 +43542,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -42937,14 +43551,14 @@ var ts; if (node === firstDeclaration) { if (enumSymbol.declarations.length > 1) { ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 238) { + if (declaration.kind !== 241) { return false; } var enumDeclaration = declaration; @@ -42967,8 +43581,8 @@ var ts; var declarations = symbol.declarations; 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))) && + if ((declaration.kind === 238 || + (declaration.kind === 237 && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304)) { return declaration; } @@ -43026,7 +43640,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, 235); + var mergedClass = ts.getDeclarationOfKind(symbol, 238); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -43069,22 +43683,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214: + case 217: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 249: - case 250: + case 252: + case 253: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243: - case 244: + case 246: + case 247: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182: - case 232: + case 184: + case 235: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -43093,12 +43707,12 @@ var ts; } break; } - case 235: case 238: - case 234: - case 236: - case 239: + case 241: case 237: + case 239: + case 242: + case 240: if (isGlobalAugmentation) { return; } @@ -43121,7 +43735,7 @@ var ts; node = node.left; } while (node.kind !== 71); return node; - case 185: + case 187: do { node = node.expression; } while (node.kind !== 71); @@ -43137,9 +43751,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 240 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 274 && !inAmbientExternalModule) { - error(moduleName, node.kind === 250 ? + var inAmbientExternalModule = node.parent.kind === 243 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -43160,13 +43774,13 @@ var ts; (symbol.flags & 67901928 ? 67901928 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 252 ? + var message = node.kind === 255 ? 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 === 252 + && node.kind === 255 && !(target.flags & 67216319) && !(node.flags & 4194304)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -43192,7 +43806,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246) { + if (importClause.namedBindings.kind === 249) { checkImportBinding(importClause.namedBindings); } else { @@ -43215,7 +43829,7 @@ var ts; if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254) { + if (node.moduleReference.kind !== 257) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319) { @@ -43246,10 +43860,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 && + var inAmbientExternalModule = node.parent.kind === 243 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 && !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 274 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -43265,7 +43879,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 || node.parent.kind === 240 || node.parent.kind === 239; + var isInAppropriateContext = node.parent.kind === 277 || node.parent.kind === 243 || node.parent.kind === 242; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -43291,8 +43905,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 274 ? node.parent : node.parent.parent; - if (container.kind === 239 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 ? node.parent : node.parent.parent; + if (container.kind === 242 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -43371,7 +43985,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 && declaration.kind !== 154) || + return (declaration.kind !== 237 && declaration.kind !== 154) || !!declaration.body; } function checkSourceElement(node) { @@ -43387,10 +44001,10 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 242: + case 238: case 239: - case 235: - case 236: - case 234: + case 237: cancellationToken.throwIfCancellationRequested(); } } @@ -43428,110 +44042,112 @@ var ts; return checkArrayType(node); case 168: return checkTupleType(node); + case 171: + case 172: + return checkUnionOrIntersectionType(node); + case 175: case 169: case 170: - return checkUnionOrIntersectionType(node); - case 173: return checkSourceElement(node.type); - case 175: + case 177: return checkTypeOperator(node); - case 171: + case 173: return checkConditionalType(node); - case 172: + case 174: return checkInferType(node); - case 179: + case 181: return checkImportType(node); - case 290: - return checkJSDocAugmentsTag(node); - case 298: - case 292: - return checkJSDocTypeAliasTag(node); - case 296: - return checkJSDocTypeTag(node); case 293: + return checkJSDocAugmentsTag(node); + case 301: + case 295: + return checkJSDocTypeAliasTag(node); + case 299: + return checkJSDocTypeTag(node); + case 296: return checkJSDocParameterTag(node); - case 284: - checkSignatureDeclaration(node); - case 282: - case 281: - case 279: - case 280: case 287: + checkSignatureDeclaration(node); + case 285: + case 284: + case 282: + case 283: + case 290: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285: + case 288: checkJSDocVariadicType(node); return; - case 278: + case 281: return checkSourceElement(node.type); - case 176: + case 178: return checkIndexedAccessType(node); - case 177: + case 179: return checkMappedType(node); - case 234: - 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); + return checkFunctionDeclaration(node); + case 216: case 243: - return checkImportEqualsDeclaration(node); - case 250: - return checkExportDeclaration(node); - case 249: - return checkExportAssignment(node); - case 215: + return checkBlock(node); + case 217: + return checkVariableStatement(node); + case 219: + return checkExpressionStatement(node); + case 220: + return checkIfStatement(node); + case 221: + return checkDoStatement(node); + case 222: + return checkWhileStatement(node); + case 223: + return checkForStatement(node); + case 224: + return checkForInStatement(node); + case 225: + return checkForOfStatement(node); + case 226: + case 227: + return checkBreakOrContinueStatement(node); + case 228: + return checkReturnStatement(node); + case 229: + return checkWithStatement(node); + case 230: + return checkSwitchStatement(node); case 231: + return checkLabeledStatement(node); + case 232: + return checkThrowStatement(node); + case 233: + return checkTryStatement(node); + case 235: + return checkVariableDeclaration(node); + case 184: + return checkBindingElement(node); + case 238: + return checkClassDeclaration(node); + case 239: + return checkInterfaceDeclaration(node); + case 240: + return checkTypeAliasDeclaration(node); + case 241: + return checkEnumDeclaration(node); + case 242: + return checkModuleDeclaration(node); + case 247: + return checkImportDeclaration(node); + case 246: + return checkImportEqualsDeclaration(node); + case 253: + return checkExportDeclaration(node); + case 252: + return checkExportAssignment(node); + case 218: + case 234: checkGrammarStatementInAmbientContext(node); return; - case 253: + case 256: return checkMissingDeclaration(node); } } @@ -43589,15 +44205,15 @@ var ts; } function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192: - case 193: + case 194: + case 195: case 154: case 153: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -43606,11 +44222,17 @@ var ts; case 157: checkAccessorDeclaration(node); break; - case 205: + case 207: checkClassExpressionDeferred(node); break; + case 259: + checkJsxSelfClosingElementDeferred(node); + break; + case 258: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -43640,7 +44262,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -43720,24 +44342,24 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239: + case 242: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 238: + case 241: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 205: + case 207: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 235: - case 236: + case 238: + case 239: if (!isStatic) { copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928); } break; - case 192: + case 194: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -43776,10 +44398,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148: - case 235: - case 236: - case 237: case 238: + case 239: + case 240: + case 241: return true; default: return false; @@ -43792,10 +44414,10 @@ var ts; return node.parent.kind === 162; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185) { + while (node.parent.kind === 187) { node = node.parent; } - return node.parent.kind === 207; + return node.parent.kind === 209; } function forEachEnclosingClass(node, callback) { var result; @@ -43826,10 +44448,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243) { + if (nodeOnRightSide.parent.kind === 246) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249) { + if (nodeOnRightSide.parent.kind === 252) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -43855,7 +44477,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 && parent.qualifier === node) { + if (parent && parent.kind === 181 && parent.qualifier === node) { return parent; } return undefined; @@ -43865,21 +44487,21 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 && + entityName.parent.kind === 187 && entityName.parent === entityName.parent.parent.left) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 && 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, 243); + var importEqualsDeclaration = ts.getAncestor(entityName, 246); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -43896,7 +44518,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 207) { + if (entityName.parent.kind === 209) { meaning = 67901928; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 67216319; @@ -43911,10 +44533,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293) { + if (entityName.parent.kind === 296) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 && entityName.parent.parent.kind === 297) { + if (entityName.parent.kind === 148 && entityName.parent.parent.kind === 300) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -43930,12 +44552,12 @@ var ts; } return resolveEntityName(entityName, 67216319, false, true); } - else if (entityName.kind === 185 || entityName.kind === 146) { + else if (entityName.kind === 187 || entityName.kind === 146) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185) { + if (entityName.kind === 187) { checkPropertyAccessExpression(entityName); } else { @@ -43948,7 +44570,7 @@ var ts; var meaning = entityName.parent.kind === 162 ? 67901928 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 262) { + else if (entityName.parent.kind === 265) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161) { @@ -43957,7 +44579,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274) { + if (node.kind === 277) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -43975,8 +44597,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 && - grandParent.kind === 180 && + else if (parent.kind === 184 && + grandParent.kind === 182 && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -43987,7 +44609,7 @@ var ts; } switch (node.kind) { case 71: - case 185: + case 187: case 146: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99: @@ -44001,7 +44623,7 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 174: + case 176: return getTypeFromThisTypeNode(node).symbol; case 97: return checkExpression(node).symbol; @@ -44014,7 +44636,7 @@ var ts; case 9: case 13: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 244 || node.parent.kind === 250) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 || node.parent.kind === 253) && 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); @@ -44030,14 +44652,14 @@ var ts; case 89: case 36: return getSymbolOfNode(node.parent); - case 179: + case 181: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271) { + if (location && location.kind === 274) { return resolveEntityName(location.name, 67216319 | 2097152); } return undefined; @@ -44098,20 +44720,20 @@ var ts; return errorType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 || expr.kind === 183); - if (expr.parent.kind === 222) { + ts.Debug.assert(expr.kind === 186 || expr.kind === 185); + if (expr.parent.kind === 225) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 200) { + if (expr.parent.kind === 202) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 270) { + if (expr.parent.kind === 273) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 183); + ts.Debug.assert(expr.parent.kind === 185); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, false, false) || errorType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); @@ -44175,7 +44797,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -44217,7 +44839,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 274) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 277) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -44251,7 +44873,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 === 213 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 216 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -44287,16 +44909,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243: - case 245: case 246: case 248: - case 252: + case 249: + case 251: + case 255: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250: + case 253: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249: + case 252: return node.expression && node.expression.kind === 71 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -44306,7 +44928,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -44372,21 +44994,22 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273: - case 185: - case 186: + case 276: + case 187: + case 188: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273) { + if (node.kind === 276) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8)) { - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -44517,7 +45140,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 && type.flags & 33554432); } @@ -44609,14 +45232,14 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 && node.parent.parent && node.parent.parent.kind === 268; + return node.parent && node.parent.kind === 209 && node.parent.parent && node.parent.parent.kind === 271; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } var meaning = 67901928 | 1920; - if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 185 && !isInHeritageClause(node))) { + if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 187 && !isInHeritageClause(node))) { meaning = 67216319 | 1048576; } var symbol = resolveEntityName(node, meaning, true); @@ -44659,7 +45282,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -44673,21 +45296,25 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 274); + return ts.getDeclarationOfKind(moduleSymbol, 277); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -44747,6 +45374,30 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -44839,7 +45490,7 @@ var ts; } switch (modifier.kind) { case 76: - if (node.kind !== 238 && node.parent.kind === 235) { + if (node.kind !== 241) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76)); } break; @@ -44859,7 +45510,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 === 240 || node.parent.kind === 274) { + else if (node.parent.kind === 243 || node.parent.kind === 277) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -44882,7 +45533,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 240 || node.parent.kind === 274) { + else if (node.parent.kind === 243 || node.parent.kind === 277) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149) { @@ -44917,7 +45568,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 235) { + else if (node.parent.kind === 238) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149) { @@ -44926,8 +45577,8 @@ var ts; flags |= 1; break; case 79: - var container = node.parent.kind === 274 ? node.parent : node.parent.parent; - if (container.kind === 239 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 ? node.parent : node.parent.parent; + if (container.kind === 242 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; @@ -44939,13 +45590,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 === 235) { + else if (node.parent.kind === 238) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } 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 === 240) { + else if ((node.parent.flags & 4194304) && node.parent.kind === 243) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -44955,14 +45606,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235) { + if (node.kind !== 238) { 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 === 235 && ts.hasModifier(node.parent, 128))) { + if (!(node.parent.kind === 238 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -45004,7 +45655,7 @@ var ts; } return false; } - else if ((node.kind === 244 || node.kind === 243) && flags & 2) { + else if ((node.kind === 247 || node.kind === 246) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 && (flags & 92) && ts.isBindingPattern(node.name)) { @@ -45035,29 +45686,29 @@ var ts; case 154: case 153: case 160: - case 239: - case 244: - case 243: - case 250: - case 249: - case 192: - case 193: + case 242: + case 247: + case 246: + case 253: + case 252: + case 194: + case 195: case 149: return false; default: - if (node.parent.kind === 240 || node.parent.kind === 274) { + if (node.parent.kind === 243 || node.parent.kind === 277) { return false; } switch (node.kind) { - case 234: - return nodeHasAnyModifiersExcept(node, 120); - case 235: - return nodeHasAnyModifiersExcept(node, 117); - case 236: - case 214: case 237: - return true; + return nodeHasAnyModifiersExcept(node, 120); case 238: + return nodeHasAnyModifiersExcept(node, 117); + case 239: + case 217: + case 240: + return true; + case 241: return nodeHasAnyModifiersExcept(node, 76); default: ts.Debug.fail(); @@ -45071,9 +45722,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154: - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -45204,7 +45855,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206) { + if (arg.kind === 208) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -45282,15 +45933,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 && computedPropertyName.expression.operatorToken.kind === 26) { + if (computedPropertyName.expression.kind === 202 && 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 === 234 || - node.kind === 192 || + ts.Debug.assert(node.kind === 237 || + node.kind === 194 || node.kind === 154); if (node.flags & 4194304) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -45307,14 +45958,14 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272) { + if (prop.kind === 275) { continue; } var name = prop.name; if (name.kind === 147) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 && !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) { @@ -45327,8 +45978,8 @@ var ts; } var currentKind = void 0; switch (prop.kind) { - case 270: - case 271: + case 273: + case 274: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); @@ -45376,7 +46027,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 === 264) { + if (attr.kind === 267) { continue; } var name = attr.name, initializer = attr.initializer; @@ -45386,7 +46037,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 && !initializer.expression) { + if (initializer && initializer.kind === 268 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -45395,12 +46046,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 && 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 === 233) { + if (forInOrOfStatement.initializer.kind === 236) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -45408,20 +46059,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 + var diagnostic = forInOrOfStatement.kind === 224 ? 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 === 221 + var diagnostic = forInOrOfStatement.kind === 224 ? 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 === 221 + var diagnostic = forInOrOfStatement.kind === 224 ? 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); @@ -45486,7 +46137,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232: + case 235: 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); @@ -45524,7 +46175,7 @@ var ts; return true; } if (node.kind === 154) { - if (node.parent.kind === 184) { + if (node.parent.kind === 186) { if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -45547,7 +46198,7 @@ var ts; 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 === 236) { + else if (node.parent.kind === 239) { 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 === 166) { @@ -45561,9 +46212,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228: + case 231: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 223 + var isMisplacedContinueLabel = node.kind === 226 && !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); @@ -45571,8 +46222,8 @@ var ts; return false; } break; - case 227: - if (node.kind === 224 && !node.label) { + case 230: + if (node.kind === 227 && !node.label) { return false; } break; @@ -45585,13 +46236,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 + var message = node.kind === 227 ? 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 === 224 + var message = node.kind === 227 ? 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); @@ -45604,7 +46255,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 === 181 || node.name.kind === 180) { + if (node.name.kind === 183 || node.name.kind === 182) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -45617,14 +46268,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 198 && expr.operator === 38 && + expr.kind === 200 && expr.operator === 38 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 && node.parent.parent.kind !== 222) { + if (node.parent.parent.kind !== 224 && node.parent.parent.kind !== 225) { if (node.flags & 4194304) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -45634,7 +46285,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } @@ -45643,19 +46294,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 || !node.type || node.initializer || node.flags & 4194304)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 || !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 && !(node.parent.parent.flags & 4194304) && ts.hasModifier(node.parent.parent, 1)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { @@ -45704,15 +46355,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217: - case 218: - case 219: - case 226: case 220: case 221: case 222: + case 229: + case 223: + case 224: + case 225: return false; - case 228: + case 231: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -45722,7 +46373,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -45789,7 +46440,7 @@ var ts; return true; } } - else if (node.parent.kind === 236) { + else if (node.parent.kind === 239) { 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; } @@ -45814,13 +46465,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 236 || - node.kind === 237 || - node.kind === 244 || - node.kind === 243 || - node.kind === 250 || - node.kind === 249 || - node.kind === 242 || + if (node.kind === 239 || + node.kind === 240 || + node.kind === 247 || + node.kind === 246 || + node.kind === 253 || + node.kind === 252 || + node.kind === 245 || ts.hasModifier(node, 2 | 1 | 512)) { return false; } @@ -45829,7 +46480,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 214) { + if (ts.isDeclaration(decl) || decl.kind === 217) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -45849,7 +46500,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 === 213 || node.parent.kind === 240 || node.parent.kind === 274) { + if (node.parent.kind === 216 || node.parent.kind === 243 || node.parent.kind === 277) { 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); @@ -45866,10 +46517,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, 178)) { + else if (ts.isChildOfNodeWithKind(node, 180)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273)) { + else if (ts.isChildOfNodeWithKind(node, 276)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -45920,8 +46571,8 @@ var ts; ts.createTypeChecker = createTypeChecker; function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 248: - case 252: + case 251: + case 255: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -45929,13 +46580,13 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245: - case 243: - case 246: case 248: + case 246: + case 249: + case 251: return true; case 71: - return decl.parent.kind === 248; + return decl.parent.kind === 251; default: return false; } @@ -45950,7 +46601,11 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -46102,7 +46757,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -46191,10 +46846,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26) || - expression.kind === 303 ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147); @@ -46553,14 +47207,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169, types); + return createUnionOrIntersectionTypeNode(171, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -46568,7 +47246,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170, types); + return createUnionOrIntersectionTypeNode(172, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -46587,7 +47265,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171); + var node = createSynthesizedNode(173); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -46605,7 +47283,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172); + var node = createSynthesizedNode(174); node.typeParameter = typeParameter; return node; } @@ -46617,7 +47295,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179); + var node = createSynthesizedNode(181); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -46635,7 +47313,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(175); node.type = type; return node; } @@ -46647,11 +47325,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174); + return createSynthesizedNode(176); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175); + var node = createSynthesizedNode(177); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -46662,7 +47340,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(178); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -46676,7 +47354,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(179); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -46694,7 +47372,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(180); node.literal = literal; return node; } @@ -46706,7 +47384,7 @@ var ts; } ts.updateLiteralTypeNode = updateLiteralTypeNode; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(182); node.elements = createNodeArray(elements); return node; } @@ -46718,7 +47396,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(183); node.elements = createNodeArray(elements); return node; } @@ -46730,7 +47408,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(184); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -46748,7 +47426,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(185); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -46762,7 +47440,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(186); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -46776,7 +47454,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(187); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072); @@ -46791,7 +47469,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(188); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -46805,7 +47483,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(189); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -46821,7 +47499,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(190); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -46837,7 +47515,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(191); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -46860,7 +47538,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(192); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -46874,7 +47552,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(193); node.expression = expression; return node; } @@ -46886,7 +47564,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(194); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -46910,7 +47588,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(195); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -46944,7 +47622,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(196); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -46956,7 +47634,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(197); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -46968,7 +47646,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196); + var node = createSynthesizedNode(198); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -46980,7 +47658,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(199); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -46992,7 +47670,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(200); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -47005,7 +47683,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199); + var node = createSynthesizedNode(201); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -47018,7 +47696,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(202); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -47035,7 +47713,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(203); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -47065,7 +47743,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(204); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -47103,7 +47781,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203); + var node = createSynthesizedNode(205); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 ? asteriskTokenOrExpression : expression; return node; @@ -47117,7 +47795,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(206); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -47129,7 +47807,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205); + var node = createSynthesizedNode(207); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47150,11 +47828,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206); + return createSynthesizedNode(208); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(209); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -47168,7 +47846,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208); + var node = createSynthesizedNode(210); node.expression = expression; node.type = type; return node; @@ -47182,7 +47860,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(211); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -47194,7 +47872,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(212); node.keywordToken = keywordToken; node.name = name; return node; @@ -47207,7 +47885,7 @@ var ts; } ts.updateMetaProperty = updateMetaProperty; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211); + var node = createSynthesizedNode(214); node.expression = expression; node.literal = literal; return node; @@ -47221,23 +47899,17 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212); + return createSynthesizedNode(215); } ts.createSemicolonClassElement = createSemicolonClassElement; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213); + var block = createSynthesizedNode(216); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -47245,7 +47917,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(217); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -47260,21 +47932,25 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215); + return createSynthesizedNode(218); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + ts.createStatement = createExpressionStatement; + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(220); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -47290,7 +47966,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218); + var node = createSynthesizedNode(221); node.statement = statement; node.expression = expression; return node; @@ -47304,7 +47980,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219); + var node = createSynthesizedNode(222); node.expression = expression; node.statement = statement; return node; @@ -47318,7 +47994,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(223); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -47336,7 +48012,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221); + var node = createSynthesizedNode(224); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -47352,7 +48028,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(225); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -47370,7 +48046,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(226); node.label = asName(label); return node; } @@ -47382,7 +48058,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224); + var node = createSynthesizedNode(227); node.label = asName(label); return node; } @@ -47394,7 +48070,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(228); node.expression = expression; return node; } @@ -47406,7 +48082,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(229); node.expression = expression; node.statement = statement; return node; @@ -47420,7 +48096,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(230); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -47434,7 +48110,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(231); node.label = asName(label); node.statement = statement; return node; @@ -47448,7 +48124,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229); + var node = createSynthesizedNode(232); node.expression = expression; return node; } @@ -47460,7 +48136,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230); + var node = createSynthesizedNode(233); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -47476,11 +48152,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231); + return createSynthesizedNode(234); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(235); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -47497,7 +48173,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(233); + var node = createSynthesizedNode(236); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); return node; @@ -47510,7 +48186,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(237); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -47536,7 +48212,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235); + var node = createSynthesizedNode(238); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47558,7 +48234,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(239); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47580,7 +48256,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237); + var node = createSynthesizedNode(240); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47600,7 +48276,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(241); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47619,7 +48295,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(242); node.flags |= flags & (16 | 4 | 512); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -47638,7 +48314,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(243); node.statements = createNodeArray(statements); return node; } @@ -47650,7 +48326,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(244); node.clauses = createNodeArray(clauses); return node; } @@ -47662,7 +48338,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(245); node.name = asName(name); return node; } @@ -47674,7 +48350,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(246); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47692,7 +48368,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(247); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -47710,7 +48386,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245); + var node = createSynthesizedNode(248); node.name = name; node.namedBindings = namedBindings; return node; @@ -47724,7 +48400,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246); + var node = createSynthesizedNode(249); node.name = name; return node; } @@ -47736,7 +48412,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(250); node.elements = createNodeArray(elements); return node; } @@ -47748,7 +48424,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(251); node.propertyName = propertyName; node.name = name; return node; @@ -47762,7 +48438,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(252); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -47779,7 +48455,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(253); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -47797,7 +48473,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(254); node.elements = createNodeArray(elements); return node; } @@ -47809,7 +48485,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(255); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -47823,7 +48499,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(257); node.expression = expression; return node; } @@ -47835,7 +48511,7 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255); + var node = createSynthesizedNode(258); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -47851,7 +48527,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(259); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -47867,7 +48543,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(260); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -47883,7 +48559,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(261); node.tagName = tagName; return node; } @@ -47895,7 +48571,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259); + var node = createSynthesizedNode(262); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -47911,7 +48587,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262); + var node = createSynthesizedNode(265); node.name = name; node.initializer = initializer; return node; @@ -47925,7 +48601,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(266); node.properties = createNodeArray(properties); return node; } @@ -47937,7 +48613,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264); + var node = createSynthesizedNode(267); node.expression = expression; return node; } @@ -47949,7 +48625,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265); + var node = createSynthesizedNode(268); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -47962,7 +48638,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266); + var node = createSynthesizedNode(269); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -47976,7 +48652,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267); + var node = createSynthesizedNode(270); node.statements = createNodeArray(statements); return node; } @@ -47988,7 +48664,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268); + var node = createSynthesizedNode(271); node.token = token; node.types = createNodeArray(types); return node; @@ -48001,7 +48677,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269); + var node = createSynthesizedNode(272); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -48015,7 +48691,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270); + var node = createSynthesizedNode(273); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -48030,7 +48706,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271); + var node = createSynthesizedNode(274); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -48044,7 +48720,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272); + var node = createSynthesizedNode(275); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } @@ -48056,7 +48732,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273); + var node = createSynthesizedNode(276); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -48076,7 +48752,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274); + var updated = createSynthesizedNode(277); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -48150,28 +48826,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301); + var node = createSynthesizedNode(304); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305); + var node = createSynthesizedNode(308); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304); + var node = createSynthesizedNode(307); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(302); + var node = createSynthesizedNode(305); node.expression = expression; node.original = original; setTextRange(node, original); @@ -48187,7 +48863,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 === 303) { + if (node.kind === 306) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { @@ -48197,7 +48873,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303); + var node = createSynthesizedNode(306); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -48210,14 +48886,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275); + var node = ts.createNode(278); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276); + var node = ts.createNode(279); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -48225,7 +48901,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277); + var node = ts.createNode(280); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -48334,7 +49010,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 274) { + if (node.kind === 277) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -48765,7 +49441,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -48783,13 +49459,13 @@ var ts; case 8: case 9: return false; - case 183: + case 185: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184: + case 186: return target.properties.length > 0; default: return true; @@ -48816,7 +49492,7 @@ var ts; } else { switch (callee.kind) { - case 185: { + case 187: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -48828,7 +49504,7 @@ var ts; } break; } - case 186: { + case 188: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -48884,9 +49560,9 @@ var ts; case 156: case 157: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270: + case 273: return createExpressionForPropertyAssignment(property, receiver); - case 271: + case 274: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154: return createExpressionForMethodDeclaration(property, receiver); @@ -49090,7 +49766,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 191) { + if (skipped.kind === 193) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -49099,15 +49775,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(200, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 203) { + && operand.kind === 205) { return false; } return true; @@ -49146,7 +49822,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 && node.operatorToken.kind === 37) { + if (node.kind === 202 && node.operatorToken.kind === 37) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -49161,7 +49837,7 @@ var ts; return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201, 55); + var conditionalPrecedence = ts.getOperatorPrecedence(203, 55); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -49172,18 +49848,16 @@ var ts; ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; function parenthesizeSubexpressionOfConditionalExpression(e) { var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 200 && emittedExpression.operatorToken.kind === 26 || - emittedExpression.kind === 303 + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 || - check.kind === 192 || - check.kind === 303 || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26) + return check.kind === 207 || + check.kind === 194 || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -49191,9 +49865,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 187: + case 189: return ts.createParen(expression); - case 188: + case 190: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -49204,7 +49878,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -49242,7 +49916,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200, 26); + var commaPrecedence = ts.getOperatorPrecedence(202, 26); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -49253,27 +49927,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 || kind === 193) { + if (kind === 194 || kind === 195) { 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 === 184 || leftmostExpressionKind === 192) { + if (leftmostExpressionKind === 186 || leftmostExpressionKind === 194) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 ? ts.createParenthesizedType(member) : member; + return member.kind === 173 ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169: - case 170: + case 171: + case 172: case 163: case 164: return ts.createParenthesizedType(member); @@ -49284,8 +49958,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165: - case 175: - case 172: + case 177: + case 174: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -49311,24 +49985,24 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199: + case 201: node = node.operand; continue; - case 200: + case 202: node = node.left; continue; - case 201: + case 203: node = node.condition; continue; - case 187: + case 189: if (stopAtCallExpressions) { return node; } - case 186: - case 185: - node = node.expression; - continue; - case 302: + case 210: + case 188: + case 187: + case 211: + case 305: node = node.expression; continue; } @@ -49336,22 +50010,27 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, false).kind === 184) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 186)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 && node.operatorToken.kind === 26 || + node.kind === 306; + } + ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { - case 191: + case 193: return (kinds & 1) !== 0; - case 190: - case 208: - case 209: + case 192: + case 210: + case 211: return (kinds & 2) !== 0; - case 302: + case 305: return (kinds & 4) !== 0; } return false; @@ -49376,7 +50055,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209) { + while (ts.isAssertionExpression(node) || node.kind === 211) { node = node.expression; } return node; @@ -49384,15 +50063,15 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - 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 302: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193: return ts.updateParen(outerExpression, expression); + case 192: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211: return ts.updateNonNullExpression(outerExpression, expression); + case 305: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { - return node.kind === 191 + return node.kind === 193 && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -49454,10 +50133,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 && node.importClause) { + if (node.kind === 247 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 && node.moduleSpecifier) { + if (node.kind === 253 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -49520,11 +50199,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270: + case 273: return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271: + case 274: return bindingElement.name; - case 272: + case 275: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -49541,10 +50220,10 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149: - case 182: + case 184: return bindingElement.dotDotDotToken; - case 204: - case 272: + case 206: + case 275: return bindingElement; } return undefined; @@ -49552,7 +50231,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182: + case 184: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -49560,7 +50239,7 @@ var ts; : propertyName; } break; - case 270: + case 273: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -49568,7 +50247,7 @@ var ts; : propertyName; } break; - case 272: + case 275: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -49582,11 +50261,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180: - case 181: + case 182: case 183: + case 185: return name.elements; - case 184: + case 186: return name.properties; } } @@ -49625,11 +50304,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181: case 183: + case 185: return convertToArrayAssignmentPattern(node); - case 180: - case 184: + case 182: + case 186: return convertToObjectAssignmentPattern(node); } } @@ -49734,7 +50413,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -49766,7 +50445,7 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 145) || kind === 174) { + if ((kind > 0 && kind <= 145) || kind === 176) { return node; } switch (kind) { @@ -49817,206 +50496,210 @@ var ts; case 167: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); case 169: - return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 170: - return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 171: - 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.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 172: - return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179: - 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.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); 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.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + 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 174: + return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); case 181: - return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + 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 175: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 177: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 178: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 179: + 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 180: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); case 182: - 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.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); case 183: - return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); case 184: - return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + 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 185: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); case 186: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); case 187: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 188: - return ts.updateNew(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 189: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 190: - return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 191: - return ts.updateParen(node, 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 192: - 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.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 193: - 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.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 194: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + 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 195: - return ts.updateTypeOf(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 196: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 198: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 199: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 200: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); case 201: - 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.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 202: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 203: - return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + 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 204: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); 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)); + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + case 206: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); case 207: - return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208: - return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + 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 209: - return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 210: - return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); case 211: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 213: - return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 212: + return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); case 214: - return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 216: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 217: - 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.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 219: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 220: - 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.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 221: - 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.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 222: - 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.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 223: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + 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 224: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + 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 225: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + 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 226: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); case 227: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); case 228: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); case 229: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 230: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 231: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 232: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); case 233: - return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234: - 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.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); case 235: - 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.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 236: - 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.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); case 237: - 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.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 238: - 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.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 239: - 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.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 240: - return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + 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 241: - return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + 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 242: - return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); + 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 243: - 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.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 244: - 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.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 245: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); case 246: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + 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 247: - return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + 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 248: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); case 249: - return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 250: - 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.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); case 251: - return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); case 252: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 253: + 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 254: - return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); case 255: - 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.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); case 257: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 258: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 259: - return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 260: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 261: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 262: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263: - return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); case 265: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 266: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); case 267: - return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 268: - return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 269: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); case 270: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 271: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); case 272: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 273: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 274: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 275: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 276: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 277: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 302: + case 305: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303: + case 306: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -50045,16 +50728,16 @@ var ts; if ((kind > 0 && kind <= 145)) { return initial; } - if ((kind >= 161 && kind <= 178)) { + if ((kind >= 161 && kind <= 180)) { return initial; } var result = initial; switch (node.kind) { - case 212: case 215: - case 206: - case 231: - case 301: + case 218: + case 208: + case 234: + case 304: break; case 146: result = reduceNode(node.left, cbNode, result); @@ -50116,48 +50799,48 @@ var ts; result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 180: - case 181: - result = reduceNodes(node.elements, cbNodes, result); - break; case 182: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; case 183: result = reduceNodes(node.elements, cbNodes, result); break; case 184: - result = reduceNodes(node.properties, cbNodes, result); + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 185: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.elements, cbNodes, result); break; case 186: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 187: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 188: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.argumentExpression, cbNode, result); + break; + case 189: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189: + case 190: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 191: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190: + case 192: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192: + case 194: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -50165,121 +50848,121 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; + case 195: + 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 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 191: - case 194: - case 195: case 196: case 197: - case 203: - case 204: - case 209: - result = reduceNode(node.expression, cbNode, result); - break; case 198: case 199: - result = reduceNode(node.operand, cbNode, result); + case 205: + case 206: + case 211: + result = reduceNode(node.expression, cbNode, result); break; case 200: + case 201: + result = reduceNode(node.operand, cbNode, result); + break; + case 202: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201: + case 203: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202: + case 204: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205: + case 207: 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 207: + case 209: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208: + case 210: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; - case 211: + case 214: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 213: + case 216: result = reduceNodes(node.statements, cbNodes, result); break; - case 214: + case 217: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216: + case 219: result = reduceNode(node.expression, cbNode, result); break; - case 217: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218: + case 221: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219: - case 226: + case 222: + case 229: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220: + case 223: 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 221: - case 222: + case 224: + case 225: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225: - case 229: + case 228: + case 232: result = reduceNode(node.expression, cbNode, result); break; - case 227: + case 230: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228: + case 231: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230: + case 233: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232: + case 235: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233: + case 236: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234: + case 237: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -50288,7 +50971,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235: + case 238: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -50296,131 +50979,131 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238: + case 241: 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 239: + case 242: 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: + case 243: result = reduceNodes(node.statements, cbNodes, result); break; - case 241: + case 244: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243: + case 246: 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 244: + case 247: 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 245: + case 248: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246: + case 249: result = reduceNode(node.name, cbNode, result); break; - case 247: - case 251: + case 250: + case 254: result = reduceNodes(node.elements, cbNodes, result); break; - case 248: - case 252: + case 251: + case 255: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249: + case 252: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250: + case 253: 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 254: + case 257: result = reduceNode(node.expression, cbNode, result); break; - case 255: + case 258: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259: + case 262: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256: - case 257: + case 259: + case 260: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263: + case 266: result = reduceNodes(node.properties, cbNodes, result); break; - case 258: + case 261: result = reduceNode(node.tagName, cbNode, result); break; - case 262: + case 265: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, 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); + result = reduceNode(node.expression, cbNode, result); break; case 268: - result = reduceNodes(node.types, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 269: - result = reduceNode(node.variableDeclaration, cbNode, result); - result = reduceNode(node.block, cbNode, result); - break; + result = reduceNode(node.expression, cbNode, result); case 270: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); + result = reduceNodes(node.statements, cbNodes, result); break; case 271: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.objectAssignmentInitializer, cbNode, result); + result = reduceNodes(node.types, cbNodes, result); break; case 272: - result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.variableDeclaration, cbNode, result); + result = reduceNode(node.block, cbNode, result); break; case 273: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; case 274: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 302: + case 275: result = reduceNode(node.expression, cbNode, result); break; - case 303: + case 276: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 277: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 305: + result = reduceNode(node.expression, cbNode, result); + break; + case 306: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -50473,7 +51156,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 207)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 209)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -50700,7 +51383,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -50817,7 +51499,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -50861,16 +51543,16 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244: + case 247: externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243: - if (node.moduleReference.kind === 254) { + case 246: + if (node.moduleReference.kind === 257) { externalImports.push(node); } break; - case 250: + case 253: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -50897,12 +51579,12 @@ var ts; } } break; - case 249: + case 252: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 214: + case 217: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -50910,7 +51592,7 @@ var ts; } } break; - case 234: + case 237: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -50928,7 +51610,7 @@ var ts; } } break; - case 235: + case 238: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -51373,12 +52055,13 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185); - context.enableSubstitution(186); + context.enableSubstitution(187); + context.enableSubstitution(188); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; var enabledSubstitutions; var classAliases; @@ -51386,14 +52069,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275) { + if (node.kind === 278) { 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 === 277) { + if (prepend.kind === 280) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -51410,27 +52093,30 @@ var ts; return visited; } function saveStateAndInvoke(node, f) { - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; onBeforeVisitNode(node); var visited = f(node); - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } function onBeforeVisitNode(node) { switch (node.kind) { - case 274: - case 241: - case 240: - case 213: - currentScope = node; + case 277: + case 244: + case 243: + case 216: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235: - case 234: + case 238: + case 237: if (ts.hasModifier(node, 2)) { break; } @@ -51438,7 +52124,10 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 235 || ts.hasModifier(node, 512)); + ts.Debug.assert(node.kind === 238 || ts.hasModifier(node, 512)); + } + if (ts.isClassDeclaration(node)) { + currentNameScope = node; } break; } @@ -51460,10 +52149,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244: - case 243: - case 249: - case 250: + case 247: + case 246: + case 252: + case 253: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -51478,13 +52167,13 @@ var ts; return node; } switch (node.kind) { - case 244: + case 247: return visitImportDeclaration(node); - case 243: + case 246: return visitImportEqualsDeclaration(node); - case 249: + case 252: return visitExportAssignment(node); - case 250: + case 253: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -51494,11 +52183,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 250 || - node.kind === 244 || - node.kind === 245 || - (node.kind === 243 && - node.moduleReference.kind === 254)) { + if (node.kind === 253 || + node.kind === 247 || + node.kind === 248 || + (node.kind === 246 && + node.moduleReference.kind === 257)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -51522,7 +52211,7 @@ var ts; case 157: case 154: return visitorWorker(node); - case 212: + case 215: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -51554,6 +52243,8 @@ var ts; case 132: case 167: case 168: + case 169: + case 170: case 166: case 161: case 148: @@ -51569,34 +52260,34 @@ var ts; case 163: case 165: case 162: - case 169: - case 170: case 171: + case 172: case 173: - case 174: case 175: case 176: case 177: case 178: + case 179: + case 180: case 160: case 150: - case 237: + case 240: return undefined; case 152: return visitPropertyDeclaration(node); - case 242: + case 245: return undefined; case 155: return visitConstructor(node); - case 236: + case 239: return ts.createNotEmittedStatement(node); - case 235: + case 238: return visitClassDeclaration(node); - case 205: - return visitClassExpression(node); - case 268: - return visitHeritageClause(node); case 207: + return visitClassExpression(node); + case 271: + return visitHeritageClause(node); + case 209: return visitExpressionWithTypeArguments(node); case 154: return visitMethodDeclaration(node); @@ -51604,36 +52295,36 @@ var ts; return visitGetAccessor(node); case 157: return visitSetAccessor(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); - case 193: + case 195: return visitArrowFunction(node); case 149: return visitParameter(node); - case 191: + case 193: return visitParenthesizedExpression(node); - case 190: - case 208: + case 192: + case 210: return visitAssertionExpression(node); - case 187: - return visitCallExpression(node); - case 188: - return visitNewExpression(node); case 189: + return visitCallExpression(node); + case 190: + return visitNewExpression(node); + case 191: return visitTaggedTemplateExpression(node); - case 209: + case 211: return visitNonNullExpression(node); - case 238: + case 241: return visitEnumDeclaration(node); - case 214: + case 217: return visitVariableStatement(node); - case 232: + case 235: return visitVariableDeclaration(node); - case 239: + case 242: return visitModuleDeclaration(node); - case 243: + case 246: return visitImportEqualsDeclaration(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -51662,7 +52353,7 @@ var ts; var facts = 0; if (ts.some(staticProperties)) facts |= 1; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95) facts |= 64; if (shouldEmitDecorateCallForClass(node)) @@ -51693,7 +52384,7 @@ var ts; : createClassDeclarationHeadWithoutDecorators(node, name, facts); var statements = [classStatement]; if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; if (facts & 1) { @@ -51836,7 +52527,7 @@ var ts; ts.addRange(statements, ts.map(propertyAssignments, transformParameterWithPropertyAssignment)); } else if (isDerivedClass) { - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } var properties = getInitializedProperties(node, false); addInitializedPropertyStatements(statements, properties, ts.createThis()); @@ -51854,7 +52545,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -51876,7 +52567,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536)); } function getInitializedProperties(node, isStatic) { return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); @@ -51895,7 +52586,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -52058,7 +52749,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } function generateConstructorDecorationExpression(node) { @@ -52141,8 +52832,8 @@ var ts; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235: - case 205: + case 238: + case 207: return ts.getFirstConstructorWithBody(node) !== undefined; case 154: case 156: @@ -52159,8 +52850,8 @@ var ts; return serializeTypeNode(node.type); case 157: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235: - case 205: + case 238: + case 207: case 154: return ts.createIdentifier("Function"); default: @@ -52220,7 +52911,7 @@ var ts; case 95: case 131: return ts.createVoidZero(); - case 173: + case 175: return serializeTypeNode(node.type); case 163: case 164: @@ -52235,7 +52926,7 @@ var ts; return ts.createIdentifier("String"); case 135: return ts.createIdentifier("Object"); - case 178: + case 180: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -52255,18 +52946,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162: return serializeTypeReferenceNode(node); - case 170: - case 169: + case 172: + case 171: return serializeUnionOrIntersectionType(node); case 165: - case 175: - case 176: case 177: + case 178: + case 179: case 166: case 119: case 142: - case 174: - case 179: + case 176: + case 181: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -52277,7 +52968,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173) { + while (typeNode.kind === 175) { typeNode = typeNode.type; } if (typeNode.kind === 131) { @@ -52304,7 +52995,7 @@ var ts; return serializedUnion || ts.createVoidZero(); } function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, true); @@ -52342,7 +53033,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); + name.parent = ts.getParseTreeNode(currentLexicalScope); if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -52516,7 +53207,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -52563,7 +53254,7 @@ var ts; return ts.updateTaggedTemplate(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression)); } function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -52574,7 +53265,7 @@ var ts; var statements = []; var emitFlags = 2; if (addVarForEnumOrModuleDeclaration(statements, node)) { - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512; } } @@ -52588,7 +53279,7 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(enumStatement, node); ts.setTextRange(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); @@ -52614,7 +53305,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } function transformEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); @@ -52664,11 +53355,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 === 274 ? 0 : 1)); + ], currentLexicalScope.kind === 277 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 238) { + if (node.kind === 241) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -52695,7 +53386,7 @@ var ts; var statements = []; var emitFlags = 2; if (addVarForEnumOrModuleDeclaration(statements, node)) { - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512; } } @@ -52709,7 +53400,7 @@ var ts; var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg])); ts.setOriginalNode(moduleStatement, node); ts.setTextRange(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); @@ -52729,7 +53420,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240) { + if (body.kind === 243) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -52753,13 +53444,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 240) { + if (body.kind !== 243) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239) { + if (moduleDeclaration.body.kind === 242) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -52779,7 +53470,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 246) { + if (node.kind === 249) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -52854,17 +53545,17 @@ var ts; && ts.hasModifier(node, 512); } function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -52914,15 +53605,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(71); - context.enableSubstitution(271); - context.enableEmitNotification(239); + context.enableSubstitution(274); + context.enableEmitNotification(242); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239; + return ts.getOriginalNode(node).kind === 242; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238; + return ts.getOriginalNode(node).kind === 241; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -52968,9 +53659,9 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 185: + case 187: return substitutePropertyAccessExpression(node); - case 186: + case 188: return substituteElementAccessExpression(node); } return node; @@ -53000,9 +53691,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 !== 274) { - var substitute = (applicableSubstitutions & 2 && container.kind === 239) || - (applicableSubstitutions & 8 && container.kind === 238); + if (container && container.kind !== 277) { + var substitute = (applicableSubstitutions & 2 && container.kind === 242) || + (applicableSubstitutions & 8 && container.kind === 241); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -53115,15 +53806,15 @@ var ts; switch (node.kind) { case 120: return undefined; - case 197: + case 199: return visitAwaitExpression(node); case 154: return visitMethodDeclaration(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); - case 193: + case 195: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -53132,27 +53823,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214: - return visitVariableStatementInAsyncBody(node); - case 220: - return visitForStatementInAsyncBody(node); - case 221: - return visitForInStatementInAsyncBody(node); - case 222: - return visitForOfStatementInAsyncBody(node); - case 269: - return visitCatchClauseInAsyncBody(node); - case 213: - case 227: - case 241: - case 266: - case 267: - case 230: - case 218: - case 219: case 217: - case 226: - case 228: + return visitVariableStatementInAsyncBody(node); + case 223: + return visitForStatementInAsyncBody(node); + case 224: + return visitForInStatementInAsyncBody(node); + case 225: + return visitForOfStatementInAsyncBody(node); + case 272: + return visitCatchClauseInAsyncBody(node); + case 216: + case 230: + case 244: + case 269: + case 270: + case 233: + case 221: + case 222: + case 220: + case 229: + case 231: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -53186,7 +53877,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -53301,7 +53992,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 === 193; + var isArrowFunction = node.kind === 195; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap(); @@ -53365,10 +54056,10 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; + context.enableSubstitution(189); context.enableSubstitution(187); - context.enableSubstitution(185); - context.enableSubstitution(186); - context.enableEmitNotification(235); + context.enableSubstitution(188); + context.enableEmitNotification(238); context.enableEmitNotification(154); context.enableEmitNotification(156); context.enableEmitNotification(157); @@ -53397,11 +54088,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185: - return substitutePropertyAccessExpression(node); - case 186: - return substituteElementAccessExpression(node); case 187: + return substitutePropertyAccessExpression(node); + case 188: + return substituteElementAccessExpression(node); + case 189: return substituteCallExpression(node); } return node; @@ -53432,7 +54123,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 + return kind === 238 || kind === 155 || kind === 154 || kind === 156 @@ -53516,25 +54207,25 @@ var ts; return node; } switch (node.kind) { - case 197: + case 199: return visitAwaitExpression(node); - case 203: + case 205: return visitYieldExpression(node); - case 225: - return visitReturnStatement(node); case 228: + return visitReturnStatement(node); + case 231: return visitLabeledStatement(node); - case 184: + case 186: return visitObjectLiteralExpression(node); - case 200: + case 202: return visitBinaryExpression(node, noDestructuringValue); - case 232: + case 235: return visitVariableDeclaration(node); - case 222: + case 225: return visitForOfStatement(node, undefined); - case 220: + case 223: return visitForStatement(node); - case 196: + case 198: return visitVoidExpression(node); case 155: return visitConstructorDeclaration(node); @@ -53544,19 +54235,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157: return visitSetAccessorDeclaration(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); - case 193: + case 195: return visitArrowFunction(node); case 149: return visitParameter(node); - case 216: + case 219: return visitExpressionStatement(node); - case 191: + case 193: return visitParenthesizedExpression(node, noDestructuringValue); - case 269: + case 272: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -53589,7 +54280,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 && statement.awaitModifier) { + if (statement.kind === 225 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -53601,7 +54292,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 === 272) { + if (e.kind === 275) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -53610,7 +54301,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 + chunkObject = ts.append(chunkObject, e.kind === 273 ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -53623,7 +54314,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 184) { + if (objects.length && objects[0].kind !== 186) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -53739,12 +54430,12 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1)), ts.createBlock([ ts.createTry(ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1) ]), undefined, ts.setEmitFlags(ts.createBlock([ ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) ]), 1)) @@ -53879,10 +54570,10 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; + context.enableSubstitution(189); context.enableSubstitution(187); - context.enableSubstitution(185); - context.enableSubstitution(186); - context.enableEmitNotification(235); + context.enableSubstitution(188); + context.enableEmitNotification(238); context.enableEmitNotification(154); context.enableEmitNotification(156); context.enableEmitNotification(157); @@ -53911,11 +54602,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185: - return substitutePropertyAccessExpression(node); - case 186: - return substituteElementAccessExpression(node); case 187: + return substitutePropertyAccessExpression(node); + case 188: + return substituteElementAccessExpression(node); + case 189: return substituteCallExpression(node); } return node; @@ -53946,7 +54637,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 + return kind === 238 || kind === 155 || kind === 154 || kind === 156 @@ -54045,13 +54736,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255: + case 258: return visitJsxElement(node, false); - case 256: - return visitJsxSelfClosingElement(node, false); case 259: + return visitJsxSelfClosingElement(node, false); + case 262: return visitJsxFragment(node, false); - case 265: + case 268: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -54061,13 +54752,13 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 265: + case 268: return visitJsxExpression(node); - case 255: + case 258: return visitJsxElement(node, true); - case 256: - return visitJsxSelfClosingElement(node, true); case 259: + return visitJsxSelfClosingElement(node, true); + case 262: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -54131,7 +54822,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265) { + else if (node.kind === 268) { if (node.expression === undefined) { return ts.createTrue(); } @@ -54191,7 +54882,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255) { + if (node.kind === 258) { return getTagName(node.openingElement); } else { @@ -54491,7 +55182,7 @@ var ts; return node; } switch (node.kind) { - case 200: + case 202: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -54581,13 +55272,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096) !== 0 - && node.kind === 225 + && node.kind === 228 && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 213))) + || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 216))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432) !== 0; } @@ -54615,63 +55306,63 @@ var ts; switch (node.kind) { case 115: return undefined; - case 235: + case 238: return visitClassDeclaration(node); - case 205: + case 207: return visitClassExpression(node); case 149: return visitParameter(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 193: + case 195: return visitArrowFunction(node); - case 192: + case 194: return visitFunctionExpression(node); - case 232: + case 235: return visitVariableDeclaration(node); case 71: return visitIdentifier(node); - case 233: + case 236: return visitVariableDeclarationList(node); - case 227: + case 230: return visitSwitchStatement(node); - case 241: + case 244: return visitCaseBlock(node); - case 213: - return visitBlock(node, false); - case 224: - case 223: - return visitBreakOrContinueStatement(node); - case 228: - return visitLabeledStatement(node); - case 218: - case 219: - return visitDoOrWhileStatement(node, undefined); - case 220: - return visitForStatement(node, undefined); - case 221: - return visitForInStatement(node, undefined); - case 222: - return visitForOfStatement(node, undefined); case 216: + return visitBlock(node, false); + case 227: + case 226: + return visitBreakOrContinueStatement(node); + case 231: + return visitLabeledStatement(node); + case 221: + case 222: + return visitDoOrWhileStatement(node, undefined); + case 223: + return visitForStatement(node, undefined); + case 224: + return visitForInStatement(node, undefined); + case 225: + return visitForOfStatement(node, undefined); + case 219: return visitExpressionStatement(node); - case 184: + case 186: return visitObjectLiteralExpression(node); - case 269: + case 272: return visitCatchClause(node); - case 271: + case 274: return visitShorthandPropertyAssignment(node); case 147: return visitComputedPropertyName(node); - case 183: + case 185: return visitArrayLiteralExpression(node); - case 187: + case 189: return visitCallExpression(node); - case 188: + case 190: return visitNewExpression(node); - case 191: + case 193: return visitParenthesizedExpression(node, true); - case 200: + case 202: return visitBinaryExpression(node, true); case 13: case 14: @@ -54682,28 +55373,28 @@ var ts; return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 189: + case 191: return visitTaggedTemplateExpression(node); - case 202: - return visitTemplateExpression(node); - case 203: - return visitYieldExpression(node); case 204: + return visitTemplateExpression(node); + case 205: + return visitYieldExpression(node); + case 206: return visitSpreadElement(node); case 97: return visitSuperKeyword(false); case 99: return visitThisKeyword(node); - case 210: + case 212: return visitMetaProperty(node); case 154: return visitMethodDeclaration(node); case 156: case 157: return visitAccessorDeclaration(node); - case 214: + case 217: return visitVariableStatement(node); - case 225: + case 228: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -54784,14 +55475,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 224 ? 2 : 4; + var jump = node.kind === 227 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224) { + if (node.kind === 227) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -54801,7 +55492,7 @@ var ts; } } else { - if (node.kind === 224) { + if (node.kind === 227) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } @@ -54860,7 +55551,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, ts.createFileLevelUniqueName("_super"))] : [], undefined, transformClassBody(node, extendsClauseElement)); ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288); var inner = ts.createPartiallyEmittedExpression(classFunction); @@ -54897,7 +55588,7 @@ var ts; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), extendsClauseElement)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { @@ -54965,17 +55656,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 225) { + if (statement.kind === 228) { return true; } - else if (statement.kind === 217) { + else if (statement.kind === 220) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 213) { + else if (statement.kind === 216) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -55004,7 +55695,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -55012,8 +55703,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 - || superCallExpression.left.kind !== 187) { + if (superCallExpression.kind !== 202 + || superCallExpression.left.kind !== 189) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -55073,13 +55764,13 @@ var ts; statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 1048576)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576)); } } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536)) ]), parameter), 1 | 32 | 384 | 1536)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -55105,7 +55796,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ - ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); @@ -55114,7 +55805,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 193) { + if (node.transformFlags & 32768 && node.kind !== 195) { captureThisForNode(statements, node, ts.createThis()); } } @@ -55132,7 +55823,7 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 193: + case 195: return statements; case 154: case 156: @@ -55142,8 +55833,8 @@ var ts; case 155: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 234: - case 192: + case 237: + case 194: 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: @@ -55163,7 +55854,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212: + case 215: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154: @@ -55195,7 +55886,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), member); + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); @@ -55203,7 +55894,7 @@ var ts; return statement; } function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false)); + var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false)); ts.setEmitFlags(statement, 1536); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; @@ -55301,7 +55992,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 234 || node.kind === 192)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 237 || node.kind === 194)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -55333,7 +56024,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193); + ts.Debug.assert(node.kind === 195); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -55386,19 +56077,19 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 191: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 200: - return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); + case 193: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false)); + case 202: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); } function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 191: + case 193: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 200: + case 202: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -55431,7 +56122,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { updated = undefined; @@ -55523,14 +56214,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218: - case 219: - return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220: - return visitForStatement(node, outermostLabeledStatement); case 221: - return visitForInStatement(node, outermostLabeledStatement); case 222: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 223: + return visitForStatement(node, outermostLabeledStatement); + case 224: + return visitForInStatement(node, outermostLabeledStatement); + case 225: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -55577,11 +56268,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -55632,12 +56323,12 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1)), ts.createBlock([ ts.createTry(ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1), ]), undefined, ts.setEmitFlags(ts.createBlock([ ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) ]), 1)) @@ -55716,11 +56407,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220: - case 221: - case 222: + case 223: + case 224: + case 225: var initializer = node.initializer; - if (initializer && initializer.kind === 233) { + if (initializer && initializer.kind === 236) { loopInitializer = initializer; } break; @@ -55846,7 +56537,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -55860,7 +56551,7 @@ var ts; ? ts.createYield(ts.createToken(39), ts.setEmitFlags(call, 8388608)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); } else { @@ -55956,10 +56647,10 @@ var ts; case 154: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270: + case 273: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271: + case 274: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -56095,7 +56786,7 @@ var ts; } statements.push(funcStatements[classBodyStart]); classBodyStart++; - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { classBodyEnd--; @@ -56165,7 +56856,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -56315,9 +57006,9 @@ var ts; context.enableEmitNotification(154); context.enableEmitNotification(156); context.enableEmitNotification(157); - context.enableEmitNotification(193); - context.enableEmitNotification(192); - context.enableEmitNotification(234); + context.enableEmitNotification(195); + context.enableEmitNotification(194); + context.enableEmitNotification(237); } } function onSubstituteNode(hint, node) { @@ -56341,10 +57032,10 @@ var ts; } function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182: - case 235: + case 184: case 238: - case 232: + case 241: + case 235: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -56405,11 +57096,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189) { return false; } var callTarget = statementExpression.expression; @@ -56417,7 +57108,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206) { return false; } var expression = callArgument.expression; @@ -56461,24 +57152,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257); - context.enableEmitNotification(258); - context.enableEmitNotification(256); + context.enableEmitNotification(260); + context.enableEmitNotification(261); + context.enableEmitNotification(259); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185); - context.enableSubstitution(270); + context.enableSubstitution(187); + context.enableSubstitution(273); return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257: - case 258: - case 256: + case 260: + case 261: + case 259: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -56595,13 +57286,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218: + case 221: return visitDoStatement(node); - case 219: + case 222: return visitWhileStatement(node); - case 227: + case 230: return visitSwitchStatement(node); - case 228: + case 231: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -56609,24 +57300,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); case 156: case 157: return visitAccessorDeclaration(node); - case 214: + case 217: return visitVariableStatement(node); - case 220: - return visitForStatement(node); - case 221: - return visitForInStatement(node); - case 224: - return visitBreakStatement(node); case 223: + return visitForStatement(node); + case 224: + return visitForInStatement(node); + case 227: + return visitBreakStatement(node); + case 226: return visitContinueStatement(node); - case 225: + case 228: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -56642,21 +57333,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200: + case 202: return visitBinaryExpression(node); - case 201: - return visitConditionalExpression(node); case 203: + return visitConditionalExpression(node); + case 205: return visitYieldExpression(node); - case 183: + case 185: return visitArrayLiteralExpression(node); - case 184: - return visitObjectLiteralExpression(node); case 186: - return visitElementAccessExpression(node); - case 187: - return visitCallExpression(node); + return visitObjectLiteralExpression(node); case 188: + return visitElementAccessExpression(node); + case 189: + return visitCallExpression(node); + case 190: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -56664,9 +57355,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -56784,7 +57475,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } function visitBinaryExpression(node) { @@ -56823,10 +57514,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185: + case 187: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186: + case 188: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -56884,7 +57575,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -56965,7 +57656,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -57027,35 +57718,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213: - return transformAndEmitBlock(node); case 216: - return transformAndEmitExpressionStatement(node); - case 217: - return transformAndEmitIfStatement(node); - case 218: - return transformAndEmitDoStatement(node); + return transformAndEmitBlock(node); case 219: - return transformAndEmitWhileStatement(node); + return transformAndEmitExpressionStatement(node); case 220: - return transformAndEmitForStatement(node); + return transformAndEmitIfStatement(node); case 221: - return transformAndEmitForInStatement(node); + return transformAndEmitDoStatement(node); + case 222: + return transformAndEmitWhileStatement(node); case 223: - return transformAndEmitContinueStatement(node); + return transformAndEmitForStatement(node); case 224: - return transformAndEmitBreakStatement(node); - case 225: - return transformAndEmitReturnStatement(node); + return transformAndEmitForInStatement(node); case 226: - return transformAndEmitWithStatement(node); + return transformAndEmitContinueStatement(node); case 227: - return transformAndEmitSwitchStatement(node); + return transformAndEmitBreakStatement(node); case 228: - return transformAndEmitLabeledStatement(node); + return transformAndEmitReturnStatement(node); case 229: - return transformAndEmitThrowStatement(node); + return transformAndEmitWithStatement(node); case 230: + return transformAndEmitSwitchStatement(node); + case 231: + return transformAndEmitLabeledStatement(node); + case 232: + return transformAndEmitThrowStatement(node); + case 233: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -57092,7 +57783,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -57186,7 +57877,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -57196,7 +57887,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -57236,7 +57927,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), undefined, [key])))); + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); var incrementLabel = defineLabel(); @@ -57258,7 +57949,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -57349,7 +58040,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 && defaultClauseIndex === -1) { + if (clause.kind === 270 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -57359,7 +58050,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266) { + if (clause.kind === 269) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -57948,7 +58639,7 @@ var ts; } if (currentExceptionBlock) { var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), undefined, [ + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), undefined, [ ts.createArrayLiteral([ createLabel(startLabel), createLabel(catchLabel), @@ -57959,7 +58650,7 @@ var ts; currentExceptionBlock = undefined; } if (markLabelEnd) { - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -58089,7 +58780,7 @@ var ts; } } function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; @@ -58175,11 +58866,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71); + context.enableSubstitution(202); context.enableSubstitution(200); - context.enableSubstitution(198); - context.enableSubstitution(199); - context.enableSubstitution(271); - context.enableEmitNotification(274); + context.enableSubstitution(201); + context.enableSubstitution(274); + context.enableEmitNotification(277); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -58231,7 +58922,7 @@ var ts; var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ + ts.createExpressionStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") @@ -58256,9 +58947,9 @@ var ts; ts.createIdentifier("exports") ])) ]), - ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, (moduleName ? [moduleName] : []).concat([ + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") @@ -58268,7 +58959,7 @@ var ts; ]))) ], true), undefined)); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createExpressionStatement(ts.createCall(umdHeader, undefined, [ ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(undefined, undefined, undefined, "require"), ts.createParameter(undefined, undefined, undefined, "exports") @@ -58318,7 +59009,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); @@ -58354,7 +59045,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536); statements.push(statement); @@ -58364,23 +59055,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 244: + case 247: return visitImportDeclaration(node); - case 243: + case 246: return visitImportEqualsDeclaration(node); - case 250: + case 253: return visitExportDeclaration(node); - case 249: + case 252: return visitExportAssignment(node); - case 214: + case 217: return visitVariableStatement(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 235: + case 238: return visitClassDeclaration(node); - case 304: + case 307: return visitMergeDeclarationMarker(node); - case 305: + case 308: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -58405,17 +59096,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270: + case 273: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271: + case 274: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272: + case 275: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -58484,7 +59175,7 @@ var ts; ts.createParameter(undefined, undefined, undefined, reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; if (languageVersion >= 2) { @@ -58541,7 +59232,7 @@ var ts; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -58584,7 +59275,7 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ @@ -58594,7 +59285,7 @@ var ts; } else { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -58621,12 +59312,12 @@ var ts; for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } function visitExportAssignment(node) { @@ -58700,7 +59391,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -58737,7 +59428,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -58769,10 +59460,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246: + case 249: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247: + case 250: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -58846,10 +59537,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), ts.createObjectLiteral([ @@ -58861,7 +59552,7 @@ var ts; return statement; } function createExportStatement(name, value, location, allowComments) { - var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536); @@ -58880,7 +59571,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274) { + if (node.kind === 277) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -58922,10 +59613,10 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 200: + case 202: return substituteBinaryExpression(node); - case 199: - case 198: + case 201: + case 200: return substituteUnaryExpression(node); } return node; @@ -58940,7 +59631,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274) { + if (exportContainer && exportContainer.kind === 277) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -58983,7 +59674,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 + var expression = node.kind === 201 ? 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++) { @@ -59047,11 +59738,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71); - context.enableSubstitution(271); + context.enableSubstitution(274); + context.enableSubstitution(202); context.enableSubstitution(200); - context.enableSubstitution(198); - context.enableSubstitution(199); - context.enableEmitNotification(274); + context.enableSubstitution(201); + context.enableEmitNotification(277); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -59084,7 +59775,7 @@ var ts; var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) ]), node.statements)), 1024); @@ -59155,7 +59846,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 && externalImport.exportClause) { + if (externalImport.kind === 253 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -59178,7 +59869,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250) { + if (externalImport.kind !== 253) { continue; } if (!externalImport.exportClause) { @@ -59213,9 +59904,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), - ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) + ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [exports])) ], true)); } function createSettersArray(exportStarFunction, dependencyGroups) { @@ -59229,15 +59920,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 244: + case 247: if (!entry.importClause) { break; } - case 243: + case 246: ts.Debug.assert(importVariableName !== undefined); - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250: + case 253: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -59245,10 +59936,10 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); } else { - statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); } break; } @@ -59259,13 +59950,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 244: + case 247: return visitImportDeclaration(node); - case 243: + case 246: return visitImportEqualsDeclaration(node); - case 250: + case 253: return undefined; - case 249: + case 252: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -59332,7 +60023,7 @@ var ts; var statements; var name = ts.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -59360,7 +60051,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { var id = ts.getOriginalNodeId(node); @@ -59386,7 +60077,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 274 + && (enclosingBlockScopedContainer.kind === 277 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -59408,7 +60099,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -59447,10 +60138,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246: + case 249: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247: + case 250: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -59536,7 +60227,7 @@ var ts; return statements; } function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536); @@ -59550,43 +60241,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 214: + case 217: return visitVariableStatement(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 235: + case 238: return visitClassDeclaration(node); - case 220: + case 223: return visitForStatement(node); - case 221: + case 224: return visitForInStatement(node); - case 222: + case 225: return visitForOfStatement(node); - case 218: + case 221: return visitDoStatement(node); - case 219: + case 222: return visitWhileStatement(node); - case 228: + case 231: return visitLabeledStatement(node); - case 226: + case 229: return visitWithStatement(node); - case 227: - return visitSwitchStatement(node); - case 241: - return visitCaseBlock(node); - case 266: - return visitCaseClause(node); - case 267: - return visitDefaultClause(node); case 230: - return visitTryStatement(node); + return visitSwitchStatement(node); + case 244: + return visitCaseBlock(node); case 269: + return visitCaseClause(node); + case 270: + return visitDefaultClause(node); + case 233: + return visitTryStatement(node); + case 272: return visitCatchClause(node); - case 213: + case 216: return visitBlock(node); - case 304: + case 307: return visitMergeDeclarationMarker(node); - case 305: + case 308: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -59680,7 +60371,7 @@ var ts; } function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 200) { + && node.kind === 202) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -59723,7 +60414,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274; + return container !== undefined && container.kind === 277; } else { return false; @@ -59738,7 +60429,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274) { + if (node.kind === 277) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -59772,7 +60463,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 271: + case 274: return substituteShorthandPropertyAssignment(node); } return node; @@ -59796,10 +60487,10 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 200: + case 202: return substituteBinaryExpression(node); - case 198: - case 199: + case 200: + case 201: return substituteUnaryExpression(node); } return node; @@ -59851,14 +60542,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 + var expression = node.kind === 201 ? 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 === 199) { + if (node.kind === 201) { expression = node.operator === 43 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -59875,7 +60566,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 274) { + if (exportContainer && exportContainer.kind === 277) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -59903,7 +60594,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274); + context.enableEmitNotification(277); context.enableSubstitution(71); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -59930,9 +60621,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243: + case 246: return undefined; - case 249: + case 252: return visitExportAssignment(node); } return node; @@ -60018,7 +60709,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 === 235) { + else if (node.parent.kind === 238) { 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 : @@ -60047,7 +60738,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 === 235) { + else if (node.parent.kind === 238) { 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 : @@ -60094,7 +60785,7 @@ var ts; 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 === 232 || node.kind === 182) { + if (node.kind === 235 || node.kind === 184) { 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 : @@ -60110,7 +60801,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 === 235 || node.kind === 149) { + else if (node.parent.kind === 238 || 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 : @@ -60195,7 +60886,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 === 235) { + else if (node.parent.kind === 238) { 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 : @@ -60208,7 +60899,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234: + case 237: 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 : @@ -60261,7 +60952,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 === 235) { + else if (node.parent.parent.kind === 238) { 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 : @@ -60273,7 +60964,7 @@ 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 234: + case 237: case 163: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -60287,10 +60978,10 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 235: + case 238: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236: + case 239: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159: @@ -60304,17 +60995,17 @@ var ts; 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 === 235) { + else if (node.parent.parent.kind === 238) { 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 234: + case 237: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237: + case 240: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -60328,7 +61019,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 235) { + if (node.parent.parent.kind === 238) { 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; @@ -60416,7 +61107,11 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -60468,10 +61163,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275) { + if (node.kind === 278) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -60499,7 +61194,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 === 277) { + if (prepend.kind === 280) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -60594,7 +61289,7 @@ var ts; return name; } else { - if (name.kind === 181) { + if (name.kind === 183) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -60602,7 +61297,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206) { + if (elem.kind === 208) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -60654,7 +61349,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 || node.kind === 182) { + if (node.kind === 235 || node.kind === 184) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 @@ -60676,19 +61371,19 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234: - case 239: - case 236: - case 235: case 237: + case 242: + case 239: case 238: + case 240: + case 241: return !resolver.isDeclarationVisible(node); - case 232: + case 235: return !getBindingNameVisible(node); - case 243: - case 244: - case 250: - case 249: + case 246: + case 247: + case 253: + case 252: return false; } return false; @@ -60741,7 +61436,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 && parent.kind !== 179); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 && parent.kind !== 181); if (input.kind === 9 && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -60753,7 +61448,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254) { + if (decl.moduleReference.kind === 257) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -60773,7 +61468,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 === 246) { + if (decl.importClause.namedBindings.kind === 249) { 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; } @@ -60853,13 +61548,13 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 || input.kind === 177) && input.parent.kind !== 237); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 || input.kind === 179) && input.parent.kind !== 240); if (shouldEnterSuppressNewDiagnosticsContextContext) { suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 207: { + case 209: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -60907,7 +61602,7 @@ var ts; case 160: { return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119))); } - case 232: { + case 235: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -60921,7 +61616,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171: { + case 173: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -60937,7 +61632,7 @@ var ts; case 164: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179: { + case 181: { 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)); @@ -60975,14 +61670,14 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250: { + case 253: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; } return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249: { + case 252: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -61010,10 +61705,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243: { + case 246: { return transformImportEqualsDeclaration(input); } - case 244: { + case 247: { return transformImportDeclaration(input); } } @@ -61033,18 +61728,18 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237: + case 240: 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 236: { + case 239: { return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 234: { + case 237: { 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 239: { + case 242: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240) { + if (inner && inner.kind === 243) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -61062,7 +61757,7 @@ var ts; return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 235: { + case 238: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -61097,7 +61792,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95) { var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); getSymbolAccessibilityDiagnostic = function () { return ({ @@ -61124,10 +61819,10 @@ var ts; return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214: { + case 217: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238: { + case 241: { 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; @@ -61144,7 +61839,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239) { + if (input.kind === 242) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -61165,7 +61860,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206) { + if (e.kind === 208) { return; } if (e.name) { @@ -61219,7 +61914,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 274; + var parentIsFile = node.parent.kind === 277; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1) | 512 | 2); additions = 0; @@ -61239,7 +61934,7 @@ var ts; var prop = ts.createProperty(undefined, maskModifiers(node, undefined, (!accessors.setAccessor) ? 64 : 0), node.name, node.questionToken, ensureType(node, accessorType), undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -61253,7 +61948,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -61266,7 +61961,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236) { + if (node.kind === 239) { return true; } return false; @@ -61294,7 +61989,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232: + case 235: case 152: case 151: case 149: @@ -61304,17 +61999,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 234: - case 239: - case 243: - case 236: - case 235: case 237: + case 242: + case 246: + case 239: case 238: - case 214: - case 244: - case 250: - case 249: + case 240: + case 241: + case 217: + case 247: + case 253: + case 252: return true; } return false; @@ -61331,14 +62026,14 @@ var ts; case 153: case 158: case 160: - case 232: + case 235: case 148: - case 207: + case 209: case 162: - case 171: + case 173: case 163: case 164: - case 179: + case 181: return true; } return false; @@ -61389,7 +62084,7 @@ var ts; } ts.getTransformers = getTransformers; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(306); + var enabledSyntaxKindFeatures = new Array(309); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -61647,7 +62342,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { @@ -61655,7 +62349,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274) { + if (sourceFileOrBundle.kind === 277) { sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { @@ -61727,7 +62421,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } function emitPos(pos) { if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { @@ -61768,6 +62461,7 @@ var ts; return typeof x === "object" && !!x.mappings && typeof x.mappings === "string" && !!x.sources; } function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -61778,43 +62472,48 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, true)); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 + if (node.kind !== 304 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -61831,7 +62530,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 + if (node.kind !== 304 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -61873,9 +62572,11 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -61974,7 +62675,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301; + var isEmittedNode = node.kind !== 304; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 10; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 10; if (!skipLeadingComments) { @@ -61988,7 +62689,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 233) { + if (node.kind === 236) { declarationListContainerEnd = end; } } @@ -62297,7 +62998,7 @@ var ts; ts.forEachEmittedFile = forEachEmittedFile; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275) { + if (sourceFile.kind === 278) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; @@ -62414,6 +63115,9 @@ var ts; var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -62438,9 +63142,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71) { + resolver.collectLinkedAliases(node.expression, true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -62527,9 +63244,9 @@ var ts; break; } switch (node.kind) { - case 274: return printFile(node); - case 275: return printBundle(node); - case 276: return printUnparsedSource(node); + case 277: return printFile(node); + case 278: return printBundle(node); + case 279: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -62673,7 +63390,7 @@ var ts; } return pipelineEmitWithoutComments; case 2: - if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { + if (onEmitSourceMapOfNode && hint !== 0) { return pipelineEmitWithSourceMap; } case 3: @@ -62698,7 +63415,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 && hint !== 2); + ts.Debug.assert(hint !== 0); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -62716,7 +63433,7 @@ var ts; case 15: case 16: return emitLiteral(node); - case 276: + case 279: return emitUnparsedSource(node); case 71: return emitIdentifier(node); @@ -62755,7 +63472,7 @@ var ts; return emitTypeReference(node); case 163: return emitFunctionType(node); - case 284: + case 287: return emitJSDocFunctionType(node); case 164: return emitConstructorType(node); @@ -62768,168 +63485,171 @@ var ts; case 168: return emitTupleType(node); case 169: - return emitUnionType(node); - case 170: - return emitIntersectionType(node); + return emitOptionalType(node); case 171: - return emitConditionalType(node); + return emitUnionType(node); case 172: - return emitInferType(node); + return emitIntersectionType(node); case 173: - return emitParenthesizedType(node); - case 207: - return emitExpressionWithTypeArguments(node); + return emitConditionalType(node); case 174: - return emitThisType(); + return emitInferType(node); case 175: - return emitTypeOperator(node); + return emitParenthesizedType(node); + case 209: + return emitExpressionWithTypeArguments(node); case 176: - return emitIndexedAccessType(node); + return emitThisType(); case 177: - return emitMappedType(node); + return emitTypeOperator(node); case 178: - return emitLiteralType(node); + return emitIndexedAccessType(node); case 179: + return emitMappedType(node); + case 180: + return emitLiteralType(node); + case 181: return emitImportTypeNode(node); - case 279: + case 282: write("*"); return; - case 280: + case 283: write("?"); return; - case 281: + case 284: return emitJSDocNullableType(node); - case 282: - return emitJSDocNonNullableType(node); - case 283: - return emitJSDocOptionalType(node); case 285: - return emitJSDocVariadicType(node); - case 180: - return emitObjectBindingPattern(node); - case 181: - return emitArrayBindingPattern(node); + return emitJSDocNonNullableType(node); + case 286: + return emitJSDocOptionalType(node); + case 170: + case 288: + return emitRestOrJSDocVariadicType(node); case 182: + return emitObjectBindingPattern(node); + case 183: + return emitArrayBindingPattern(node); + case 184: return emitBindingElement(node); - case 211: - return emitTemplateSpan(node); - case 212: - return emitSemicolonClassElement(); - case 213: - return emitBlock(node); case 214: - return emitVariableStatement(node); + return emitTemplateSpan(node); case 215: - return emitEmptyStatement(); + return emitSemicolonClassElement(); case 216: - return emitExpressionStatement(node); + return emitBlock(node); case 217: - return emitIfStatement(node); + return emitVariableStatement(node); case 218: - return emitDoStatement(node); + return emitEmptyStatement(); case 219: - return emitWhileStatement(node); + return emitExpressionStatement(node); case 220: - return emitForStatement(node); + return emitIfStatement(node); case 221: - return emitForInStatement(node); + return emitDoStatement(node); case 222: - return emitForOfStatement(node); + return emitWhileStatement(node); case 223: - return emitContinueStatement(node); + return emitForStatement(node); case 224: - return emitBreakStatement(node); + return emitForInStatement(node); case 225: - return emitReturnStatement(node); + return emitForOfStatement(node); case 226: - return emitWithStatement(node); + return emitContinueStatement(node); case 227: - return emitSwitchStatement(node); + return emitBreakStatement(node); case 228: - return emitLabeledStatement(node); + return emitReturnStatement(node); case 229: - return emitThrowStatement(node); + return emitWithStatement(node); case 230: - return emitTryStatement(node); + return emitSwitchStatement(node); case 231: - return emitDebuggerStatement(node); + return emitLabeledStatement(node); case 232: - return emitVariableDeclaration(node); + return emitThrowStatement(node); case 233: - return emitVariableDeclarationList(node); + return emitTryStatement(node); case 234: - return emitFunctionDeclaration(node); + return emitDebuggerStatement(node); case 235: - return emitClassDeclaration(node); + return emitVariableDeclaration(node); case 236: - return emitInterfaceDeclaration(node); + return emitVariableDeclarationList(node); case 237: - return emitTypeAliasDeclaration(node); + return emitFunctionDeclaration(node); case 238: - return emitEnumDeclaration(node); + return emitClassDeclaration(node); case 239: - return emitModuleDeclaration(node); + return emitInterfaceDeclaration(node); case 240: - return emitModuleBlock(node); + return emitTypeAliasDeclaration(node); case 241: - return emitCaseBlock(node); + return emitEnumDeclaration(node); case 242: - return emitNamespaceExportDeclaration(node); + return emitModuleDeclaration(node); case 243: - return emitImportEqualsDeclaration(node); + return emitModuleBlock(node); case 244: - return emitImportDeclaration(node); + return emitCaseBlock(node); case 245: - return emitImportClause(node); + return emitNamespaceExportDeclaration(node); case 246: - return emitNamespaceImport(node); + return emitImportEqualsDeclaration(node); case 247: - return emitNamedImports(node); + return emitImportDeclaration(node); case 248: - return emitImportSpecifier(node); + return emitImportClause(node); case 249: - return emitExportAssignment(node); + return emitNamespaceImport(node); case 250: - return emitExportDeclaration(node); + return emitNamedImports(node); case 251: - return emitNamedExports(node); + return emitImportSpecifier(node); case 252: - return emitExportSpecifier(node); + return emitExportAssignment(node); case 253: - return; + return emitExportDeclaration(node); case 254: + return emitNamedExports(node); + case 255: + return emitExportSpecifier(node); + case 256: + return; + case 257: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 257: case 260: - return emitJsxOpeningElementOrFragment(node); - case 258: - case 261: - return emitJsxClosingElementOrFragment(node); - case 262: - return emitJsxAttribute(node); case 263: - return emitJsxAttributes(node); + return emitJsxOpeningElementOrFragment(node); + case 261: case 264: - return emitJsxSpreadAttribute(node); + return emitJsxClosingElementOrFragment(node); case 265: - return emitJsxExpression(node); + return emitJsxAttribute(node); case 266: - return emitCaseClause(node); + return emitJsxAttributes(node); case 267: - return emitDefaultClause(node); + return emitJsxSpreadAttribute(node); case 268: - return emitHeritageClause(node); + return emitJsxExpression(node); case 269: - return emitCatchClause(node); + return emitCaseClause(node); case 270: - return emitPropertyAssignment(node); + return emitDefaultClause(node); case 271: - return emitShorthandPropertyAssignment(node); + return emitHeritageClause(node); case 272: - return emitSpreadAssignment(node); + return emitCatchClause(node); case 273: + return emitPropertyAssignment(node); + case 274: + return emitShorthandPropertyAssignment(node); + case 275: + return emitSpreadAssignment(node); + case 276: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -62958,69 +63678,69 @@ var ts; case 91: writeTokenNode(node, writeKeyword); return; - case 183: - return emitArrayLiteralExpression(node); - case 184: - return emitObjectLiteralExpression(node); case 185: - return emitPropertyAccessExpression(node); + return emitArrayLiteralExpression(node); case 186: - return emitElementAccessExpression(node); + return emitObjectLiteralExpression(node); case 187: - return emitCallExpression(node); + return emitPropertyAccessExpression(node); case 188: - return emitNewExpression(node); + return emitElementAccessExpression(node); case 189: - return emitTaggedTemplateExpression(node); + return emitCallExpression(node); case 190: - return emitTypeAssertionExpression(node); + return emitNewExpression(node); case 191: - return emitParenthesizedExpression(node); + return emitTaggedTemplateExpression(node); case 192: - return emitFunctionExpression(node); + return emitTypeAssertionExpression(node); case 193: - return emitArrowFunction(node); + return emitParenthesizedExpression(node); case 194: - return emitDeleteExpression(node); + return emitFunctionExpression(node); case 195: - return emitTypeOfExpression(node); + return emitArrowFunction(node); case 196: - return emitVoidExpression(node); + return emitDeleteExpression(node); case 197: - return emitAwaitExpression(node); + return emitTypeOfExpression(node); case 198: - return emitPrefixUnaryExpression(node); + return emitVoidExpression(node); case 199: - return emitPostfixUnaryExpression(node); + return emitAwaitExpression(node); case 200: - return emitBinaryExpression(node); + return emitPrefixUnaryExpression(node); case 201: - return emitConditionalExpression(node); + return emitPostfixUnaryExpression(node); case 202: - return emitTemplateExpression(node); + return emitBinaryExpression(node); case 203: - return emitYieldExpression(node); + return emitConditionalExpression(node); case 204: - return emitSpreadExpression(node); + return emitTemplateExpression(node); case 205: - return emitClassExpression(node); + return emitYieldExpression(node); case 206: - return; + return emitSpreadExpression(node); + case 207: + return emitClassExpression(node); case 208: - return emitAsExpression(node); - case 209: - return emitNonNullExpression(node); + return; case 210: + return emitAsExpression(node); + case 211: + return emitNonNullExpression(node); + case 212: return emitMetaProperty(node); - case 255: + case 258: return emitJsxElement(node); - case 256: - return emitJsxSelfClosingElement(node); case 259: + return emitJsxSelfClosingElement(node); + case 262: return emitJsxFragment(node); - case 302: + case 305: return emitPartiallyEmittedExpression(node); - case 303: + case 306: return emitCommaList(node); } } @@ -63037,7 +63757,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 ? node : undefined; + var bundle = node.kind === 278 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -63136,7 +63856,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 && !node.name) { + if (node.parent && node.parent.kind === 287 && !node.name) { emit(node.type); } else { @@ -63298,7 +64018,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -63307,6 +64027,10 @@ var ts; emitList(node, node.elementTypes, 272); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260); } @@ -63565,7 +64289,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 198 + return operand.kind === 200 && ((node.operator === 37 && (operand.operator === 37 || operand.operator === 43)) || (node.operator === 38 && (operand.operator === 38 || operand.operator === 44))); } @@ -63679,7 +64403,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217) { + if (node.elseStatement.kind === 220) { writeSpace(); emit(node.elseStatement); } @@ -63750,7 +64474,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233) { + if (node.kind === 236) { emit(node); } else { @@ -63849,7 +64573,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272); } @@ -64035,7 +64759,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239) { + while (body.kind === 242) { writePunctuation("."); emit(body.name); body = body.body; @@ -64890,7 +65614,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -64949,81 +65673,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213: + case 216: ts.forEach(node.statements, generateNames); break; - case 228: - case 226: - case 218: - case 219: + case 231: + case 229: + case 221: + case 222: generateNames(node.statement); break; - case 217: + case 220: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220: - case 222: - case 221: + case 223: + case 225: + case 224: generateNames(node.initializer); generateNames(node.statement); break; - case 227: + case 230: generateNames(node.caseBlock); break; - case 241: + case 244: ts.forEach(node.clauses, generateNames); break; - case 266: - case 267: + case 269: + case 270: ts.forEach(node.statements, generateNames); break; - case 230: + case 233: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269: + case 272: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214: + case 217: generateNames(node.declarationList); break; - case 233: + case 236: ts.forEach(node.declarations, generateNames); break; - case 232: - case 149: - case 182: case 235: + case 149: + case 184: + case 238: generateNameIfNeeded(node.name); break; - case 234: + case 237: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180: - case 181: + case 182: + case 183: ts.forEach(node.elements, generateNames); break; - case 244: + case 247: generateNames(node.importClause); break; - case 245: + case 248: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246: + case 249: generateNameIfNeeded(node.name); break; - case 247: + case 250: ts.forEach(node.elements, generateNames); break; - case 248: + case 251: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -65032,8 +65756,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270: - case 271: + case 273: + case 274: case 152: case 154: case 156: @@ -65171,17 +65895,17 @@ var ts; switch (node.kind) { case 71: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); - case 239: - case 238: + case 242: + case 241: return generateNameForModuleOrEnum(node); - case 244: - case 250: + case 247: + case 253: return generateNameForImportOrExportDeclaration(node); - case 234: - case 235: - case 249: + case 237: + case 238: + case 252: return generateNameForExportDefault(); - case 205: + case 207: return generateNameForClassExpression(); case 154: case 156: @@ -65773,17 +66497,19 @@ var ts; } return context; } - function formatLocation(file, start, host) { + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -65802,11 +66528,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -66398,7 +67124,14 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -66619,51 +67352,51 @@ var ts; case 155: case 156: case 157: - case 192: - case 234: - case 193: - case 232: + case 194: + case 237: + case 195: + case 235: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 243: + case 246: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249: + case 252: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268: + case 271: 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 236: + case 239: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239: + case 242: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237: + case 240: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238: + case 241: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209: + case 211: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208: + case 210: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190: + case 192: ts.Debug.fail(); } var prevParent = parent; @@ -66676,22 +67409,22 @@ 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 235: + case 238: case 154: case 153: case 155: case 156: case 157: - case 192: - case 234: - case 193: + case 194: + case 237: + case 195: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 214: + case 217: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214); + return checkModifiers(nodes, parent.kind === 217); } break; case 152: @@ -66711,11 +67444,11 @@ var ts; return; } break; - case 187: - case 188: - case 207: - case 256: - case 257: + case 189: + case 190: + case 209: + case 259: + case 260: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -67310,14 +68043,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -68692,10 +69425,11 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -68707,7 +69441,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); 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); @@ -68724,13 +69458,13 @@ var ts; 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); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } 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); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -68773,11 +69507,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0) { resolvedParts.pop(); originalParts.pop(); } @@ -68810,14 +69545,13 @@ var ts; } return [target]; } - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -68887,7 +69621,7 @@ var ts; return undefined; } var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); - if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); function getDirectoryOrExtensionlessFileName(path) { @@ -69243,7 +69977,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; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -69716,16 +70450,19 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1) ? ".jsx" : ".js"); + var newExtension = ts.fileExtensionIs(inputFileName, ".json") ? ".json" : + ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ? ".jsx" : ".js"; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts")) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json")) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -69894,9 +70631,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -69941,7 +70675,7 @@ var ts; if (!graph.buildQueue) { return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { system.watchFile(resolved, function () { @@ -69965,7 +70699,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -70157,13 +70891,17 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -70171,7 +70909,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -70436,10 +71178,10 @@ var ts; upstreamProjectName: ref.path }; } - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -70506,7 +71248,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } break; case UpToDateStatusType.UpToDateWithUpstreamTypes: @@ -70541,9 +71283,12 @@ var ts; reportDiagnostic = ts.createDiagnosticReporter(ts.sys, /*pretty*/ true); } } + function defaultIsPretty() { + return !!ts.sys.writeOutputIsTTY && ts.sys.writeOutputIsTTY(); + } function shouldBePretty(options) { if (typeof options.pretty === "undefined") { - return !!ts.sys.writeOutputIsTTY && ts.sys.writeOutputIsTTY(); + return defaultIsPretty(); } return options.pretty; } @@ -70567,7 +71312,7 @@ var ts; } function executeCommandLine(args) { if (args.length > 0 && ((args[0].toLowerCase() === "--build") || (args[0].toLowerCase() === "-b"))) { - var reportDiag_1 = ts.createDiagnosticReporter(ts.sys, /*pretty*/ true); + var reportDiag_1 = ts.createDiagnosticReporter(ts.sys, defaultIsPretty()); var report = function (message) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 0fe2f989a21..7dbe902b21a 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -16,31 +16,67 @@ and limitations under the License. "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); }; "use strict"; -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + 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; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - return t; }; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } @@ -892,23 +928,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1869,8 +1888,9 @@ 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; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2210,160 +2230,163 @@ var ts; 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["OptionalType"] = 169] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; // Expression - 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["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; // Element - 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["Block"] = 216] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; // JSX - 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["JsxElement"] = 258] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; // The ? type - 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["JSDocThisTag"] = 295] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 296] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 297] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 298] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 299] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 296] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 297] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 298] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 299] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 300] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 301] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 302] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 300] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 303] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 301] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 302] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 303] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 304] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 305] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 304] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 305] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 306] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 307] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 308] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 306] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 309] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -2376,7 +2399,7 @@ var ts; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; @@ -2390,10 +2413,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 299] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 299] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 302] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 302] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -2567,6 +2590,7 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; @@ -2786,6 +2810,8 @@ var ts; CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; CheckFlags[CheckFlags["Late"] = 1024] = "Late"; CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped"; + CheckFlags[CheckFlags["OptionalParameter"] = 4096] = "OptionalParameter"; + CheckFlags[CheckFlags["RestParameter"] = 8192] = "RestParameter"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var InternalSymbolName; @@ -4420,6 +4446,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -4578,7 +4607,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -4698,6 +4726,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -4728,7 +4758,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -4798,6 +4828,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -4847,6 +4878,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -4994,6 +5026,9 @@ var ts; 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'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), 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."), @@ -5080,6 +5115,8 @@ var ts; 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}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), 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}'."), @@ -5379,6 +5416,10 @@ var ts; 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), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), 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}"), @@ -5410,6 +5451,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -5441,6 +5484,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -5585,6 +5629,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -7733,7 +7781,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274 /* SourceFile */) { + while (node && node.kind !== 277 /* SourceFile */) { node = node.parent; } return node; @@ -7741,11 +7789,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return true; } return false; @@ -7883,7 +7931,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 === 300 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 303 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7976,14 +8024,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { @@ -7997,7 +8037,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; + return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -8029,11 +8069,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 === 239 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 /* SourceFile */ || - node.kind === 239 /* ModuleDeclaration */ || + return node.kind === 277 /* SourceFile */ || + node.kind === 242 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8050,9 +8090,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 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node.parent); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8064,22 +8104,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 269 /* CatchClause */: - case 239 /* ModuleDeclaration */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 272 /* CatchClause */: + case 242 /* ModuleDeclaration */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; - case 213 /* Block */: + case 216 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8095,22 +8135,22 @@ var ts; 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 297 /* JSDocTemplateTag */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: - case 288 /* JSDocSignature */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 291 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -8120,8 +8160,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8130,15 +8170,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - 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 */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 217 /* VariableStatement */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -8159,7 +8199,7 @@ var ts; // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -8186,7 +8226,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8231,7 +8271,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213 /* Block */) { + if (node.body && node.body.kind === 216 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8245,7 +8285,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* 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 @@ -8254,25 +8294,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 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 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: errorNode = node.name; break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8304,35 +8344,34 @@ var ts; return file.scriptKind === 6 /* JSON */; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */ && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */) - || !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 /* ImportType */ && - n.argument.kind === 178 /* LiteralType */ && + return n.kind === 181 /* ImportType */ && + n.argument.kind === 180 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 /* ExpressionStatement */ + return node.kind === 219 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -8343,9 +8382,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 /* Parameter */ || node.kind === 148 /* TypeParameter */ || - node.kind === 192 /* FunctionExpression */ || - node.kind === 193 /* ArrowFunction */ || - node.kind === 191 /* ParenthesizedExpression */) ? + node.kind === 194 /* FunctionExpression */ || + node.kind === 195 /* ArrowFunction */ || + node.kind === 193 /* 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 '/**/' @@ -8361,7 +8400,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -8375,11 +8414,11 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 196 /* VoidExpression */; - case 207 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 198 /* VoidExpression */; + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148 /* TypeParameter */: - return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; + return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: @@ -8387,20 +8426,20 @@ var ts; if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 187 /* 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 === 146 /* QualifiedName */ || node.kind === 185 /* 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 === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through case 146 /* QualifiedName */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: { var parent = node.parent; if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 179 /* ImportType */) { + if (parent.kind === 181 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8409,22 +8448,22 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148 /* TypeParameter */: return node === parent.constraint; case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return node === parent.type; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -8435,12 +8474,12 @@ var ts; case 159 /* ConstructSignature */: case 160 /* IndexSignature */: return node === parent.type; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return node === parent.type; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8465,23 +8504,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitor(node); - 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 */: + case 244 /* CaseBlock */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8491,19 +8530,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -8546,12 +8585,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 166 /* TypeLiteral */: return node.members; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.properties; } } @@ -8559,14 +8598,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182 /* BindingElement */: - case 273 /* EnumMember */: + case 184 /* BindingElement */: + case 276 /* EnumMember */: case 149 /* Parameter */: - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 271 /* ShorthandPropertyAssignment */: - case 232 /* VariableDeclaration */: + case 274 /* ShorthandPropertyAssignment */: + case 235 /* VariableDeclaration */: return true; } } @@ -8578,12 +8617,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 /* VariableDeclarationList */ - && node.parent.parent.kind === 214 /* VariableStatement */; + return node.parent.kind === 236 /* VariableDeclarationList */ + && node.parent.parent.kind === 217 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -8595,8 +8634,8 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return true; } return false; @@ -8607,7 +8646,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228 /* LabeledStatement */) { + if (node.statement.kind !== 231 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -8615,17 +8654,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 184 /* ObjectLiteralExpression */ || - node.parent.kind === 205 /* ClassExpression */); + (node.parent.kind === 186 /* ObjectLiteralExpression */ || + node.parent.kind === 207 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8638,7 +8677,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270 /* PropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -8675,7 +8714,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274 /* SourceFile */); + ts.Debug.assert(node.kind !== 277 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -8710,14 +8749,14 @@ var ts; node = node.parent; } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 239 /* ModuleDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 242 /* ModuleDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 154 /* MethodDeclaration */: @@ -8728,8 +8767,8 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 238 /* EnumDeclaration */: - case 274 /* SourceFile */: + case 241 /* EnumDeclaration */: + case 277 /* SourceFile */: return node; } } @@ -8740,8 +8779,8 @@ var ts; if (container) { switch (container.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return container; } } @@ -8766,9 +8805,9 @@ var ts; case 147 /* ComputedPropertyName */: node = node.parent; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!stopOnFunctions) { continue; } @@ -8799,14 +8838,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { + if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 191 /* ParenthesizedExpression */) { + while (parent.kind === 193 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -8817,7 +8856,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -8826,7 +8865,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -8834,7 +8873,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -8847,10 +8886,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return node.tag; - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -8859,25 +8898,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // classes are valid targets return true; case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 235 /* ClassDeclaration */; + return parent.kind === 238 /* 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 === 235 /* ClassDeclaration */; + && parent.kind === 238 /* 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 === 155 /* Constructor */ || parent.kind === 154 /* MethodDeclaration */ || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 235 /* ClassDeclaration */; + && grandparent.kind === 238 /* ClassDeclaration */; } return false; } @@ -8893,7 +8932,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 case 154 /* MethodDeclaration */: case 157 /* SetAccessor */: @@ -8905,9 +8944,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 /* JsxOpeningElement */ || - parent.kind === 256 /* JsxSelfClosingElement */ || - parent.kind === 258 /* JsxClosingElement */) { + if (parent.kind === 260 /* JsxOpeningElement */ || + parent.kind === 259 /* JsxSelfClosingElement */ || + parent.kind === 261 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -8920,37 +8959,37 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - 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 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: + case 210 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 211 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 206 /* SpreadElement */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 206 /* OmittedExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 203 /* YieldExpression */: - case 197 /* AwaitExpression */: - case 210 /* MetaProperty */: + case 208 /* OmittedExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 205 /* YieldExpression */: + case 199 /* AwaitExpression */: + case 212 /* MetaProperty */: return true; case 146 /* QualifiedName */: while (node.parent.kind === 146 /* QualifiedName */) { @@ -8974,47 +9013,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 182 /* BindingElement */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 184 /* BindingElement */: return parent.initializer === node; - 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 */: + case 219 /* ExpressionStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 228 /* ReturnStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 232 /* ThrowStatement */: return parent.expression === node; - case 220 /* ForStatement */: + case 223 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forInStatement.expression === node; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return node === parent.expression; - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return node === parent.expression; case 147 /* ComputedPropertyName */: return node === parent.expression; case 150 /* Decorator */: - case 265 /* JsxExpression */: - case 264 /* JsxSpreadAttribute */: - case 272 /* SpreadAssignment */: + case 268 /* JsxExpression */: + case 267 /* JsxSpreadAttribute */: + case 275 /* SpreadAssignment */: return true; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -9022,7 +9061,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9031,7 +9070,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -9063,7 +9102,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187 /* CallExpression */) { + if (callExpression.kind !== 189 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -9159,11 +9198,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 192 /* FunctionExpression */ || - initializer.kind === 205 /* ClassExpression */ || - initializer.kind === 193 /* ArrowFunction */) { + if (initializer.kind === 194 /* FunctionExpression */ || + initializer.kind === 207 /* ClassExpression */ || + initializer.kind === 195 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9232,7 +9271,7 @@ var ts; return false; } function getRightMostAssignedExpression(node) { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -9255,6 +9294,14 @@ var ts; return 0 /* None */; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + // F.prototype = { ... } + return 6 /* Prototype */; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } @@ -9263,11 +9310,7 @@ var ts; return 2 /* ModuleExports */; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - // F.prototype = { ... } - return 6 /* Prototype */; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } @@ -9287,7 +9330,7 @@ var ts; } return 0 /* None */; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -9301,7 +9344,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9311,14 +9354,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.parent; - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return node.parent.parent; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return node.parent; - case 178 /* LiteralType */: + case 180 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9328,12 +9371,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.moduleSpecifier; - case 243 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 179 /* ImportType */: + case 246 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 181 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9342,11 +9385,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9354,7 +9397,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -9363,8 +9406,8 @@ var ts; case 149 /* Parameter */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 271 /* ShorthandPropertyAssignment */: - case 270 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return node.questionToken !== undefined; @@ -9374,14 +9417,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 /* JSDocFunctionType */ && + return node.kind === 287 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 301 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9406,12 +9449,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152 /* PropertyDeclaration */: return node.initializer; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return node.initializer; } } @@ -9421,59 +9464,57 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 /* ModuleDeclaration */ + node.body.kind === 242 /* ModuleDeclaration */ ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - 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. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } - } - // Pull parameter comments from declaring function as well - 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)) { - result = ts.addRange(result, node.initializer.jsDoc); - } + // Pull parameter comments from declaring function as well + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } + if (node.kind === 149 /* Parameter */) { + result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; + } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 /* PropertyAssignment */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + return parent; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -9522,7 +9563,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9535,31 +9576,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 191 /* ParenthesizedExpression */: - case 183 /* ArrayLiteralExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 185 /* ArrayLiteralExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: node = parent; break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -9586,22 +9627,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - 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 */: + case 216 /* Block */: + case 217 /* VariableStatement */: + case 229 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return true; } return false; @@ -9618,15 +9659,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173 /* ParenthesizedType */); + return walkUp(node, 175 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191 /* ParenthesizedExpression */); + return walkUp(node, 193 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */) { + while (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -9634,11 +9675,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 !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194 /* DeleteExpression */; + return node && node.kind === 196 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9695,9 +9736,9 @@ var ts; case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 185 /* PropertyAccessExpression */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 187 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; case 146 /* QualifiedName */: @@ -9709,12 +9750,12 @@ var ts; return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 182 /* BindingElement */: - case 248 /* ImportSpecifier */: + case 184 /* BindingElement */: + case 251 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 252 /* ExportSpecifier */: - case 262 /* JsxAttribute */: + case 255 /* ExportSpecifier */: + case 265 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -9730,13 +9771,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(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) || + return node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 245 /* NamespaceExportDeclaration */ || + node.kind === 248 /* ImportClause */ && !!node.name || + node.kind === 249 /* NamespaceImport */ || + node.kind === 251 /* ImportSpecifier */ || + node.kind === 255 /* ExportSpecifier */ || + node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9745,11 +9786,22 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + // Prefer an @augments tag because it may have type parameters. + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; @@ -9758,7 +9810,7 @@ var ts; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -9831,14 +9883,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -9852,9 +9904,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined @@ -9960,7 +10012,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182 /* BindingElement */) { + while (node.kind === 184 /* BindingElement */) { node = node.parent.parent; } return node; @@ -9969,14 +10021,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 /* Constructor */ - || kind === 192 /* FunctionExpression */ - || kind === 234 /* FunctionDeclaration */ - || kind === 193 /* ArrowFunction */ + || kind === 194 /* FunctionExpression */ + || kind === 237 /* FunctionDeclaration */ + || kind === 195 /* ArrowFunction */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ - || kind === 239 /* ModuleDeclaration */ - || kind === 274 /* SourceFile */; + || kind === 242 /* ModuleDeclaration */ + || kind === 277 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9995,23 +10047,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: return 1 /* Right */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -10035,15 +10087,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200 /* BinaryExpression */) { + if (expression.kind === 202 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { + else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10053,15 +10105,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return 0; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return 1; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return 2; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return 4; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -10082,21 +10134,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: return 16; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return 17; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return 18; - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 19 : 18; - case 189 /* TaggedTemplateExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 191 /* TaggedTemplateExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -10106,19 +10158,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - 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 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 191 /* ParenthesizedExpression */: - case 206 /* OmittedExpression */: + case 204 /* TemplateExpression */: + case 193 /* ParenthesizedExpression */: + case 208 /* OmittedExpression */: return 20; default: return -1; @@ -10177,6 +10229,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -10184,6 +10237,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -10606,7 +10676,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 289 /* 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); @@ -10618,7 +10688,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -10911,8 +10981,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 184 /* ObjectLiteralExpression */ - || kind === 183 /* ArrayLiteralExpression */; + return kind === 186 /* ObjectLiteralExpression */ + || kind === 185 /* ArrayLiteralExpression */; } return false; } @@ -10922,7 +10992,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */ + return node.kind === 209 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -10944,16 +11014,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); + (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 /* ObjectLiteralExpression */ && + return expression.kind === 186 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 /* ArrayLiteralExpression */ && + return expression.kind === 185 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11294,8 +11364,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11372,21 +11442,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 185 /* PropertyAccessExpression */: + case 187 /* 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 === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -11489,7 +11559,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -11559,6 +11629,11 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + /* @internal */ + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; // Returns true if 'span' contains 'other'. function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -11752,7 +11827,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { return current; } } @@ -11777,27 +11852,34 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232 /* VariableDeclaration */) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236 /* VariableDeclarationList */) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217 /* VariableStatement */) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags @@ -11807,19 +11889,7 @@ var ts; // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** @@ -11927,16 +11997,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -11953,17 +12013,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return expr.name; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11972,10 +12032,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 228 /* LabeledStatement */: { + case 231 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11987,7 +12047,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -11998,29 +12058,20 @@ 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; - } + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71 /* Identifier */: return declaration; - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: { + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -12032,17 +12083,22 @@ var ts; return undefined; } } - case 292 /* JSDocCallbackTag */: - return declaration.name; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -12331,545 +12387,545 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169 /* UnionType */; + return node.kind === 171 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170 /* IntersectionType */; + return node.kind === 172 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171 /* ConditionalType */; + return node.kind === 173 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172 /* InferType */; + return node.kind === 174 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173 /* ParenthesizedType */; + return node.kind === 175 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174 /* ThisType */; + return node.kind === 176 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175 /* TypeOperator */; + return node.kind === 177 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176 /* IndexedAccessType */; + return node.kind === 178 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177 /* MappedType */; + return node.kind === 179 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178 /* LiteralType */; + return node.kind === 180 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179 /* ImportType */; + return node.kind === 181 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 180 /* ObjectBindingPattern */; + return node.kind === 182 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181 /* ArrayBindingPattern */; + return node.kind === 183 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182 /* BindingElement */; + return node.kind === 184 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 183 /* ArrayLiteralExpression */; + return node.kind === 185 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184 /* ObjectLiteralExpression */; + return node.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185 /* PropertyAccessExpression */; + return node.kind === 187 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186 /* ElementAccessExpression */; + return node.kind === 188 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187 /* CallExpression */; + return node.kind === 189 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188 /* NewExpression */; + return node.kind === 190 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189 /* TaggedTemplateExpression */; + return node.kind === 191 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190 /* TypeAssertionExpression */; + return node.kind === 192 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191 /* ParenthesizedExpression */; + return node.kind === 193 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302 /* PartiallyEmittedExpression */) { + while (node.kind === 305 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192 /* FunctionExpression */; + return node.kind === 194 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193 /* ArrowFunction */; + return node.kind === 195 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194 /* DeleteExpression */; + return node.kind === 196 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195 /* TypeOfExpression */; + return node.kind === 197 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196 /* VoidExpression */; + return node.kind === 198 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197 /* AwaitExpression */; + return node.kind === 199 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198 /* PrefixUnaryExpression */; + return node.kind === 200 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199 /* PostfixUnaryExpression */; + return node.kind === 201 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200 /* BinaryExpression */; + return node.kind === 202 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201 /* ConditionalExpression */; + return node.kind === 203 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202 /* TemplateExpression */; + return node.kind === 204 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203 /* YieldExpression */; + return node.kind === 205 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204 /* SpreadElement */; + return node.kind === 206 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205 /* ClassExpression */; + return node.kind === 207 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206 /* OmittedExpression */; + return node.kind === 208 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208 /* AsExpression */; + return node.kind === 210 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209 /* NonNullExpression */; + return node.kind === 211 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210 /* MetaProperty */; + return node.kind === 212 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 211 /* TemplateSpan */; + return node.kind === 214 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212 /* SemicolonClassElement */; + return node.kind === 215 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 213 /* Block */; + return node.kind === 216 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214 /* VariableStatement */; + return node.kind === 217 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215 /* EmptyStatement */; + return node.kind === 218 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216 /* ExpressionStatement */; + return node.kind === 219 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217 /* IfStatement */; + return node.kind === 220 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218 /* DoStatement */; + return node.kind === 221 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219 /* WhileStatement */; + return node.kind === 222 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220 /* ForStatement */; + return node.kind === 223 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221 /* ForInStatement */; + return node.kind === 224 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222 /* ForOfStatement */; + return node.kind === 225 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223 /* ContinueStatement */; + return node.kind === 226 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224 /* BreakStatement */; + return node.kind === 227 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; + return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225 /* ReturnStatement */; + return node.kind === 228 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226 /* WithStatement */; + return node.kind === 229 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227 /* SwitchStatement */; + return node.kind === 230 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228 /* LabeledStatement */; + return node.kind === 231 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229 /* ThrowStatement */; + return node.kind === 232 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230 /* TryStatement */; + return node.kind === 233 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231 /* DebuggerStatement */; + return node.kind === 234 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232 /* VariableDeclaration */; + return node.kind === 235 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233 /* VariableDeclarationList */; + return node.kind === 236 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234 /* FunctionDeclaration */; + return node.kind === 237 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235 /* ClassDeclaration */; + return node.kind === 238 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236 /* InterfaceDeclaration */; + return node.kind === 239 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237 /* TypeAliasDeclaration */; + return node.kind === 240 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */; + return node.kind === 241 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */; + return node.kind === 242 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240 /* ModuleBlock */; + return node.kind === 243 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241 /* CaseBlock */; + return node.kind === 244 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242 /* NamespaceExportDeclaration */; + return node.kind === 245 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */; + return node.kind === 246 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244 /* ImportDeclaration */; + return node.kind === 247 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245 /* ImportClause */; + return node.kind === 248 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246 /* NamespaceImport */; + return node.kind === 249 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247 /* NamedImports */; + return node.kind === 250 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248 /* ImportSpecifier */; + return node.kind === 251 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249 /* ExportAssignment */; + return node.kind === 252 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250 /* ExportDeclaration */; + return node.kind === 253 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251 /* NamedExports */; + return node.kind === 254 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252 /* ExportSpecifier */; + return node.kind === 255 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253 /* MissingDeclaration */; + return node.kind === 256 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 254 /* ExternalModuleReference */; + return node.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 255 /* JsxElement */; + return node.kind === 258 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256 /* JsxSelfClosingElement */; + return node.kind === 259 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257 /* JsxOpeningElement */; + return node.kind === 260 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258 /* JsxClosingElement */; + return node.kind === 261 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259 /* JsxFragment */; + return node.kind === 262 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260 /* JsxOpeningFragment */; + return node.kind === 263 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261 /* JsxClosingFragment */; + return node.kind === 264 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262 /* JsxAttribute */; + return node.kind === 265 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263 /* JsxAttributes */; + return node.kind === 266 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264 /* JsxSpreadAttribute */; + return node.kind === 267 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265 /* JsxExpression */; + return node.kind === 268 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 266 /* CaseClause */; + return node.kind === 269 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267 /* DefaultClause */; + return node.kind === 270 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268 /* HeritageClause */; + return node.kind === 271 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269 /* CatchClause */; + return node.kind === 272 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 270 /* PropertyAssignment */; + return node.kind === 273 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271 /* ShorthandPropertyAssignment */; + return node.kind === 274 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272 /* SpreadAssignment */; + return node.kind === 275 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 274 /* SourceFile */; + return node.kind === 277 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275 /* Bundle */; + return node.kind === 278 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276 /* UnparsedSource */; + return node.kind === 279 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 278 /* JSDocTypeExpression */; + return node.kind === 281 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279 /* JSDocAllType */; + return node.kind === 282 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280 /* JSDocUnknownType */; + return node.kind === 283 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281 /* JSDocNullableType */; + return node.kind === 284 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282 /* JSDocNonNullableType */; + return node.kind === 285 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283 /* JSDocOptionalType */; + return node.kind === 286 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284 /* JSDocFunctionType */; + return node.kind === 287 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285 /* JSDocVariadicType */; + return node.kind === 288 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286 /* JSDocComment */; + return node.kind === 289 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290 /* JSDocAugmentsTag */; + return node.kind === 293 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291 /* JSDocClassTag */; + return node.kind === 294 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295 /* JSDocThisTag */; + return node.kind === 298 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293 /* JSDocParameterTag */; + return node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294 /* JSDocReturnTag */; + return node.kind === 297 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296 /* JSDocTypeTag */; + return node.kind === 299 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297 /* JSDocTemplateTag */; + return node.kind === 300 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298 /* JSDocTypedefTag */; + return node.kind === 301 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299 /* JSDocPropertyTag */; + return node.kind === 302 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; + return node.kind === 302 /* JSDocPropertyTag */ || node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287 /* JSDocTypeLiteral */; + return node.kind === 290 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288 /* JSDocSignature */; + return node.kind === 291 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -12880,7 +12936,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 300 /* SyntaxList */; + return n.kind === 303 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -12995,8 +13051,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 180 /* ObjectBindingPattern */ - || kind === 181 /* ArrayBindingPattern */; + || kind === 182 /* ObjectBindingPattern */ + || kind === 183 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13011,13 +13067,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; default: return false; @@ -13028,11 +13084,11 @@ var ts; switch (kind) { case 153 /* MethodSignature */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: case 164 /* ConstructorType */: return true; default: @@ -13054,11 +13110,11 @@ var ts; || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ || kind === 160 /* IndexSignature */ - || kind === 212 /* SemicolonClassElement */; + || kind === 215 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); + return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -13093,9 +13149,9 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 /* PropertyAssignment */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 272 /* SpreadAssignment */ + return kind === 273 /* PropertyAssignment */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 275 /* SpreadAssignment */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */; @@ -13103,7 +13159,7 @@ var ts; ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ @@ -13116,14 +13172,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 207 /* ExpressionWithTypeArguments */ - || kind === 279 /* JSDocAllType */ - || kind === 280 /* JSDocUnknownType */ - || kind === 281 /* JSDocNullableType */ - || kind === 282 /* JSDocNonNullableType */ - || kind === 283 /* JSDocOptionalType */ - || kind === 284 /* JSDocFunctionType */ - || kind === 285 /* JSDocVariadicType */; + || kind === 209 /* ExpressionWithTypeArguments */ + || kind === 282 /* JSDocAllType */ + || kind === 283 /* JSDocUnknownType */ + || kind === 284 /* JSDocNullableType */ + || kind === 285 /* JSDocNonNullableType */ + || kind === 286 /* JSDocOptionalType */ + || kind === 287 /* JSDocFunctionType */ + || kind === 288 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13148,8 +13204,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 /* ArrayBindingPattern */ - || kind === 180 /* ObjectBindingPattern */; + return kind === 183 /* ArrayBindingPattern */ + || kind === 182 /* ObjectBindingPattern */; } return false; } @@ -13157,15 +13213,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 /* ArrayLiteralExpression */ - || kind === 184 /* ObjectLiteralExpression */; + return kind === 185 /* ArrayLiteralExpression */ + || kind === 186 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 /* BindingElement */ - || kind === 206 /* OmittedExpression */; + return kind === 184 /* BindingElement */ + || kind === 208 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13174,9 +13230,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return true; } return false; @@ -13197,8 +13253,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return true; } return false; @@ -13210,8 +13266,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return true; } return false; @@ -13220,25 +13276,25 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */ - || kind === 179 /* ImportType */; + || kind === 181 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: case 150 /* Decorator */: return true; default: @@ -13247,12 +13303,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; + return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 /* TemplateExpression */ + return kind === 204 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13263,32 +13319,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - 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 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 190 /* NewExpression */: + case 189 /* CallExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 191 /* TaggedTemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 193 /* ParenthesizedExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 209 /* NonNullExpression */: - case 210 /* MetaProperty */: + case 211 /* NonNullExpression */: + case 212 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13302,13 +13358,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 190 /* TypeAssertionExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 192 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13317,9 +13373,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -13338,15 +13394,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: - case 193 /* ArrowFunction */: - case 200 /* BinaryExpression */: - case 204 /* SpreadElement */: - case 208 /* AsExpression */: - case 206 /* OmittedExpression */: - case 303 /* CommaListExpression */: - case 302 /* PartiallyEmittedExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: + case 195 /* ArrowFunction */: + case 202 /* BinaryExpression */: + case 206 /* SpreadElement */: + case 210 /* AsExpression */: + case 208 /* OmittedExpression */: + case 306 /* CommaListExpression */: + case 305 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13354,18 +13410,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 /* TypeAssertionExpression */ - || kind === 208 /* AsExpression */; + return kind === 192 /* TypeAssertionExpression */ + || kind === 210 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 302 /* PartiallyEmittedExpression */; + return node.kind === 305 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 301 /* NotEmittedStatement */; + return node.kind === 304 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -13376,13 +13432,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return true; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13390,7 +13446,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; + return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13414,113 +13470,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */ + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */; + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 239 /* ModuleDeclaration */; + || kind === 242 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 /* NamedImports */ - || kind === 246 /* NamespaceImport */; + return kind === 250 /* NamedImports */ + || kind === 249 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; + return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 /* ArrowFunction */ - || kind === 182 /* BindingElement */ - || kind === 235 /* ClassDeclaration */ - || kind === 205 /* ClassExpression */ + return kind === 195 /* ArrowFunction */ + || kind === 184 /* BindingElement */ + || kind === 238 /* ClassDeclaration */ + || kind === 207 /* ClassExpression */ || kind === 155 /* Constructor */ - || kind === 238 /* EnumDeclaration */ - || kind === 273 /* EnumMember */ - || kind === 252 /* ExportSpecifier */ - || kind === 234 /* FunctionDeclaration */ - || kind === 192 /* FunctionExpression */ + || kind === 241 /* EnumDeclaration */ + || kind === 276 /* EnumMember */ + || kind === 255 /* ExportSpecifier */ + || kind === 237 /* FunctionDeclaration */ + || kind === 194 /* FunctionExpression */ || kind === 156 /* GetAccessor */ - || kind === 245 /* ImportClause */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 248 /* ImportSpecifier */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 262 /* JsxAttribute */ + || kind === 248 /* ImportClause */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 251 /* ImportSpecifier */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 265 /* JsxAttribute */ || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ - || kind === 239 /* ModuleDeclaration */ - || kind === 242 /* NamespaceExportDeclaration */ - || kind === 246 /* NamespaceImport */ + || kind === 242 /* ModuleDeclaration */ + || kind === 245 /* NamespaceExportDeclaration */ + || kind === 249 /* NamespaceImport */ || kind === 149 /* Parameter */ - || kind === 270 /* PropertyAssignment */ + || kind === 273 /* PropertyAssignment */ || kind === 152 /* PropertyDeclaration */ || kind === 151 /* PropertySignature */ || kind === 157 /* SetAccessor */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 237 /* TypeAliasDeclaration */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 240 /* TypeAliasDeclaration */ || kind === 148 /* TypeParameter */ - || kind === 232 /* VariableDeclaration */ - || kind === 298 /* JSDocTypedefTag */ - || kind === 292 /* JSDocCallbackTag */ - || kind === 299 /* JSDocPropertyTag */; + || kind === 235 /* VariableDeclaration */ + || kind === 301 /* JSDocTypedefTag */ + || kind === 295 /* JSDocCallbackTag */ + || kind === 302 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - 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 */; + return kind === 237 /* FunctionDeclaration */ + || kind === 256 /* MissingDeclaration */ + || kind === 238 /* ClassDeclaration */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 240 /* TypeAliasDeclaration */ + || kind === 241 /* EnumDeclaration */ + || kind === 242 /* ModuleDeclaration */ + || kind === 247 /* ImportDeclaration */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 253 /* ExportDeclaration */ + || kind === 252 /* ExportAssignment */ + || kind === 245 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - 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 === 301 /* NotEmittedStatement */ - || kind === 305 /* EndOfDeclarationMarker */ - || kind === 304 /* MergeDeclarationMarker */; + return kind === 227 /* BreakStatement */ + || kind === 226 /* ContinueStatement */ + || kind === 234 /* DebuggerStatement */ + || kind === 221 /* DoStatement */ + || kind === 219 /* ExpressionStatement */ + || kind === 218 /* EmptyStatement */ + || kind === 224 /* ForInStatement */ + || kind === 225 /* ForOfStatement */ + || kind === 223 /* ForStatement */ + || kind === 220 /* IfStatement */ + || kind === 231 /* LabeledStatement */ + || kind === 228 /* ReturnStatement */ + || kind === 230 /* SwitchStatement */ + || kind === 232 /* ThrowStatement */ + || kind === 233 /* TryStatement */ + || kind === 217 /* VariableStatement */ + || kind === 222 /* WhileStatement */ + || kind === 229 /* WithStatement */ + || kind === 304 /* NotEmittedStatement */ + || kind === 308 /* EndOfDeclarationMarker */ + || kind === 307 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 297 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -13547,10 +13603,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213 /* Block */) + if (node.kind !== 216 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { + if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { return false; } } @@ -13560,7 +13616,7 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 254 /* ExternalModuleReference */ + return kind === 257 /* ExternalModuleReference */ || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } @@ -13571,62 +13627,62 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 185 /* PropertyAccessExpression */; + || kind === 187 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 255 /* JsxElement */ - || kind === 265 /* JsxExpression */ - || kind === 256 /* JsxSelfClosingElement */ + return kind === 258 /* JsxElement */ + || kind === 268 /* JsxExpression */ + || kind === 259 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 259 /* JsxFragment */; + || kind === 262 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 /* JsxAttribute */ - || kind === 264 /* JsxSpreadAttribute */; + return kind === 265 /* JsxAttribute */ + || kind === 267 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 265 /* JsxExpression */; + || kind === 268 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 /* JsxOpeningElement */ - || kind === 256 /* JsxSelfClosingElement */; + return kind === 260 /* JsxOpeningElement */ + || kind === 259 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 /* CaseClause */ - || kind === 267 /* DefaultClause */; + return kind === 269 /* CaseClause */ + || kind === 270 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 299 /* LastJSDocNode */; + return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 302 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 /* 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 >= 289 /* FirstJSDocTagNode */ && node.kind <= 299 /* LastJSDocTagNode */; + return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 302 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -13669,22 +13725,22 @@ var ts; 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 */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: + case 179 /* MappedType */: + case 192 /* TypeAssertionExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 210 /* AsExpression */: + case 235 /* VariableDeclaration */: + case 237 /* FunctionDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 281 /* JSDocTypeExpression */: + case 284 /* JSDocNullableType */: + case 285 /* JSDocNonNullableType */: + case 286 /* JSDocOptionalType */: + case 287 /* JSDocFunctionType */: + case 288 /* JSDocVariadicType */: return true; } return false; @@ -13704,10 +13760,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -13719,7 +13775,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13756,7 +13812,7 @@ var ts; (function (ts) { /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; + return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -13897,6 +13953,13 @@ var ts; } /* @internal */ function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + /* @internal */ + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -13904,7 +13967,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; + } + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -14447,17 +14522,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.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; - } + function isDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; // Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. @@ -15010,7 +15083,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 274 /* SourceFile */) { + if (kind === 277 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -15074,14 +15147,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* 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 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -15106,20 +15179,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270 /* PropertyAssignment */: + case 273 /* 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 232 /* VariableDeclaration */: + case 235 /* 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 182 /* BindingElement */: + case 184 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15141,9 +15214,9 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15168,290 +15241,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172 /* InferType */: + case 174 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 179 /* ImportType */: + case 181 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: return visitNode(cbNode, node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177 /* MappedType */: + case 179 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return visitNode(cbNode, node.literal); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitNode(cbNode, node.name); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return visitNode(cbNode, node.label); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* 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 236 /* InterfaceDeclaration */: + case 239 /* 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 237 /* TypeAliasDeclaration */: + case 240 /* 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 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 278 /* JSDocTypeExpression */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 281 /* JSDocTypeExpression */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 286 /* JSDocOptionalType */: + case 288 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 282 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 281 /* JSDocNullableType */: - return visitNode(cbNode, node.type); - case 283 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 286 /* JSDocComment */: + case 289 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15460,17 +15531,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 278 /* JSDocTypeExpression */) { + node.typeExpression.kind === 281 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15478,18 +15549,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292 /* JSDocCallbackTag */: + case 295 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295 /* JSDocThisTag */: + case 298 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocSignature */: + case 291 /* 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 287 /* JSDocTypeLiteral */: + case 290 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15497,7 +15568,7 @@ var ts; } } return; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15711,7 +15782,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216 /* ExpressionStatement */); + var statement = createNode(219 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15828,13 +15899,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); // Should only be called once per node + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -15870,7 +15938,7 @@ 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(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16677,7 +16745,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 152 /* PropertyDeclaration */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return true; case 154 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -16694,8 +16762,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: return true; } } @@ -16704,42 +16772,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - 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 */: + case 237 /* FunctionDeclaration */: + case 217 /* VariableStatement */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 219 /* ExpressionStatement */: + case 232 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 230 /* SwitchStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 218 /* EmptyStatement */: + case 233 /* TryStatement */: + case 231 /* LabeledStatement */: + case 221 /* DoStatement */: + case 234 /* DebuggerStatement */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -16755,7 +16823,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232 /* VariableDeclaration */) { + if (node.kind !== 235 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16881,7 +16949,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -16943,7 +17016,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202 /* TemplateExpression */); + var template = createNode(204 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -16955,7 +17028,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211 /* TemplateSpan */); + var span = createNode(214 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -17021,10 +17094,9 @@ var ts; case 163 /* FunctionType */: case 164 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17038,14 +17110,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174 /* ThisType */); + var node = createNode(176 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279 /* JSDocAllType */); + var result = createNode(282 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, result); + return createPostfixType(286 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17053,7 +17125,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282 /* JSDocNonNullableType */); + var result = createNode(285 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17077,18 +17149,18 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(280 /* JSDocUnknownType */, pos); + var result = createNode(283 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(281 /* JSDocNullableType */, pos); + var result = createNode(284 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -17110,12 +17182,12 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, type); + return createPostfixType(286 /* JSDocOptionalType */, type); } return type; } @@ -17455,7 +17527,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177 /* MappedType */); + var node = createNode(179 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17477,13 +17549,26 @@ var ts; parseExpected(18 /* CloseBraceToken */); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24 /* DotDotDotToken */)) { + var node = createNode(170 /* RestType */, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 169 /* OptionalType */; + } + return type; + } function parseTupleType() { var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173 /* ParenthesizedType */); + var node = createNode(175 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); parseExpected(20 /* CloseParenToken */); @@ -17501,10 +17586,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178 /* LiteralType */); + var node = createNode(180 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17525,7 +17610,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(179 /* ImportType */); + var node = createNode(181 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17651,19 +17736,19 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); + type = createPostfixType(285 /* 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(281 /* JSDocNullableType */, type); + type = createPostfixType(284 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(176 /* IndexedAccessType */, type.pos); + var node = createNode(178 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); @@ -17682,21 +17767,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175 /* TypeOperator */); + var node = createNode(177 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172 /* InferType */); + var node = createNode(174 /* InferType */); parseExpected(126 /* InferKeyword */); var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); @@ -17729,10 +17814,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17816,7 +17901,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(171 /* ConditionalType */, type.pos); + var node = createNode(173 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -18009,7 +18094,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203 /* YieldExpression */); + var node = createNode(205 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -18031,11 +18116,11 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193 /* ArrowFunction */, asyncModifier.pos); + node = createNode(195 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193 /* ArrowFunction */, identifier.pos); + node = createNode(195 /* ArrowFunction */, identifier.pos); } var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; @@ -18233,7 +18318,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193 /* ArrowFunction */); + var node = createNodeWithJSDoc(195 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18297,7 +18382,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(201 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18377,39 +18462,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200 /* BinaryExpression */, left.pos); + var node = createNode(202 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208 /* AsExpression */, left.pos); + var node = createNode(210 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194 /* DeleteExpression */); + var node = createNode(196 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195 /* TypeOfExpression */); + var node = createNode(197 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196 /* VoidExpression */); + var node = createNode(198 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18425,7 +18510,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197 /* AwaitExpression */); + var node = createNode(199 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18469,7 +18554,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 192 /* 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 { @@ -18566,7 +18651,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18579,7 +18664,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18635,7 +18720,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(210 /* MetaProperty */, fullStart); + var node = createNode(212 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18710,7 +18795,7 @@ 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(185 /* PropertyAccessExpression */, expression.pos); + var node = createNode(187 /* 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); @@ -18719,8 +18804,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257 /* JsxOpeningElement */) { - var node = createNode(255 /* JsxElement */, opening.pos); + if (opening.kind === 260 /* JsxOpeningElement */) { + var node = createNode(258 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18729,15 +18814,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260 /* JsxOpeningFragment */) { - var node = createNode(259 /* JsxFragment */, opening.pos); + else if (opening.kind === 263 /* JsxOpeningFragment */) { + var node = createNode(262 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18752,7 +18837,7 @@ 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(200 /* BinaryExpression */, result.pos); + var badNode = createNode(202 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -18810,7 +18895,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263 /* JsxAttributes */); + var jsxAttributes = createNode(266 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18819,7 +18904,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18831,7 +18916,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(257 /* JsxOpeningElement */, fullStart); + node = createNode(260 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18843,7 +18928,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(256 /* JsxSelfClosingElement */, fullStart); + node = createNode(259 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18860,7 +18945,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18868,7 +18953,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265 /* JsxExpression */); + var node = createNode(268 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18890,7 +18975,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262 /* JsxAttribute */); + var node = createNode(265 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18905,7 +18990,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264 /* JsxSpreadAttribute */); + var node = createNode(267 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18913,7 +18998,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258 /* JsxClosingElement */); + var node = createNode(261 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18926,7 +19011,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261 /* JsxClosingFragment */); + var node = createNode(264 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18941,7 +19026,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190 /* TypeAssertionExpression */); + var node = createNode(192 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18952,7 +19037,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18960,14 +19045,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(211 /* 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(186 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(188 /* 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); @@ -18994,7 +19079,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -19018,7 +19103,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -19026,7 +19111,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19138,28 +19223,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204 /* SpreadElement */); + var node = createNode(206 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183 /* ArrayLiteralExpression */); + var node = createNode(185 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19171,7 +19256,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 272 /* SpreadAssignment */; + node.kind = 275 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19198,7 +19283,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 = 271 /* ShorthandPropertyAssignment */; + node.kind = 274 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -19206,14 +19291,14 @@ var ts; } } else { - node.kind = 270 /* PropertyAssignment */; + node.kind = 273 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184 /* ObjectLiteralExpression */); + var node = createNode(186 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19232,7 +19317,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(192 /* FunctionExpression */); + var node = createNodeWithJSDoc(194 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19257,7 +19342,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(210 /* MetaProperty */, fullStart); + var node_2 = createNode(212 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19274,7 +19359,7 @@ var ts; } break; } - var node = createNode(188 /* NewExpression */, fullStart); + var node = createNode(190 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19284,7 +19369,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213 /* Block */); + var node = createNode(216 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19317,12 +19402,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215 /* EmptyStatement */); + var node = createNode(218 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(217 /* IfStatement */); + var node = createNode(220 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19332,7 +19417,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218 /* DoStatement */); + var node = createNode(221 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19347,7 +19432,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219 /* WhileStatement */); + var node = createNode(222 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19371,7 +19456,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(222 /* ForOfStatement */, pos); + var forOfStatement = createNode(225 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19379,14 +19464,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(221 /* ForInStatement */, pos); + var forInStatement = createNode(224 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220 /* ForStatement */, pos); + var forStatement = createNode(223 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19404,7 +19489,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19412,7 +19497,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225 /* ReturnStatement */); + var node = createNode(228 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19421,7 +19506,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226 /* WithStatement */); + var node = createNode(229 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19430,7 +19515,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266 /* CaseClause */); + var node = createNode(269 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19438,7 +19523,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267 /* DefaultClause */); + var node = createNode(270 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19448,12 +19533,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227 /* SwitchStatement */); + var node = createNode(230 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(241 /* CaseBlock */); + var caseBlock = createNode(244 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19468,7 +19553,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(229 /* ThrowStatement */); + var node = createNode(232 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19476,7 +19561,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(230 /* TryStatement */); + var node = createNode(233 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19489,7 +19574,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269 /* CatchClause */); + var result = createNode(272 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19503,7 +19588,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231 /* DebuggerStatement */); + var node = createNode(234 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19515,12 +19600,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 228 /* LabeledStatement */; + node.kind = 231 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216 /* ExpressionStatement */; + node.kind = 219 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19687,16 +19772,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19706,9 +19791,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(223 /* ContinueStatement */); + return parseBreakOrContinueStatement(226 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(224 /* BreakStatement */); + return parseBreakOrContinueStatement(227 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19805,7 +19890,7 @@ 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(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -19828,16 +19913,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(206 /* OmittedExpression */); + return createNode(208 /* OmittedExpression */); } - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19853,14 +19938,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180 /* ObjectBindingPattern */); + var node = createNode(182 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181 /* ArrayBindingPattern */); + var node = createNode(183 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19882,7 +19967,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232 /* VariableDeclaration */); + var node = createNode(235 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19895,7 +19980,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233 /* VariableDeclarationList */); + var node = createNode(236 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19933,13 +20018,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 214 /* VariableStatement */; + node.kind = 217 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234 /* FunctionDeclaration */; + node.kind = 237 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -20121,7 +20206,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(212 /* SemicolonClassElement */); + var result = createNode(215 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -20158,10 +20243,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -20204,14 +20289,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(268 /* HeritageClause */); + var node = createNode(271 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -20228,7 +20313,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236 /* InterfaceDeclaration */; + node.kind = 239 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20237,7 +20322,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237 /* TypeAliasDeclaration */; + node.kind = 240 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20251,13 +20336,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(273 /* EnumMember */); + var node = createNodeWithJSDoc(276 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238 /* EnumDeclaration */; + node.kind = 241 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20270,7 +20355,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240 /* ModuleBlock */); + var node = createNode(243 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20281,7 +20366,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* 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 */; @@ -20293,7 +20378,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -20339,7 +20424,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 242 /* NamespaceExportDeclaration */; + node.kind = 245 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20357,7 +20442,7 @@ var ts; } } // Import statement - node.kind = 244 /* ImportDeclaration */; + node.kind = 247 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20372,7 +20457,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243 /* ImportEqualsDeclaration */; + node.kind = 246 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20386,7 +20471,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(245 /* ImportClause */, fullStart); + var importClause = createNode(248 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20396,7 +20481,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); } return finishNode(importClause); } @@ -20406,7 +20491,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(254 /* ExternalModuleReference */); + var node = createNode(257 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20429,7 +20514,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(246 /* NamespaceImport */); + var namespaceImport = createNode(249 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20444,14 +20529,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252 /* ExportSpecifier */); + return parseImportOrExportSpecifier(255 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248 /* ImportSpecifier */); + return parseImportOrExportSpecifier(251 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20476,19 +20561,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250 /* ExportDeclaration */; + node.kind = 253 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(254 /* 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. @@ -20501,7 +20586,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249 /* ExportAssignment */; + node.kind = 252 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20521,10 +20606,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ - || node.kind === 244 /* ImportDeclaration */ - || node.kind === 249 /* ExportAssignment */ - || node.kind === 250 /* ExportDeclaration */ + || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ + || node.kind === 247 /* ImportDeclaration */ + || node.kind === 252 /* ExportAssignment */ + || node.kind === 253 /* ExportDeclaration */ ? node : undefined; } @@ -20587,7 +20672,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20647,17 +20732,16 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var state = 1 /* SawAsterisk */; @@ -20743,9 +20827,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -20757,7 +20840,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286 /* JSDocComment */, start); + var result = createNode(289 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20874,6 +20957,16 @@ var ts; indent += whitespace.length; } break; + case 17 /* OpenBraceToken */: + state = 2 /* SavingComments */; + if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token @@ -20895,7 +20988,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289 /* JSDocTag */, atToken.pos); + var result = createNode(292 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20955,8 +21048,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(299 /* JSDocPropertyTag */, atToken.pos) : - createNode(293 /* JSDocParameterTag */, atToken.pos); + createNode(302 /* JSDocPropertyTag */, atToken.pos) : + createNode(296 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -20976,18 +21069,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281 /* 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 === 293 /* JSDocParameterTag */ || child.kind === 299 /* JSDocPropertyTag */) { + if (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -20998,27 +21091,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocReturnTag */, atToken.pos); + var result = createNode(297 /* 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 === 296 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296 /* JSDocTypeTag */, atToken.pos); + var result = createNode(299 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -21026,7 +21119,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -21038,7 +21131,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(185 /* PropertyAccessExpression */, node.pos); + var prop = createNode(187 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -21046,13 +21139,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291 /* JSDocClassTag */, atToken.pos); + var tag = createNode(294 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295 /* JSDocThisTag */, atToken.pos); + var tag = createNode(298 /* JSDocThisTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); @@ -21062,7 +21155,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(301 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21078,9 +21171,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 296 /* JSDocTypeTag */) { + if (child.kind === 299 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21112,7 +21205,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21126,7 +21219,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21135,7 +21228,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288 /* JSDocSignature */, start); + var jsdocSignature = createNode(291 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -21143,7 +21236,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 294 /* JSDocReturnTag */) { + if (tag && tag.kind === 297 /* JSDocReturnTag */) { return tag; } } @@ -21188,9 +21281,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 /* JSDocParameterTag */ && + if (child && (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -21264,7 +21357,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(300 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22068,6 +22161,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -23237,7 +23331,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 !== 270 /* PropertyAssignment */) { + if (element.kind !== 273 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -23314,13 +23408,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198 /* PrefixUnaryExpression */: + case 200 /* 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 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -23337,7 +23431,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25425,24 +25519,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 238 /* EnumDeclaration */: - if (ts.isConst(node)) { + case 241 /* EnumDeclaration */: + if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 240 /* ModuleBlock */: { + case 243 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -25464,7 +25558,7 @@ var ts; }); return state_1; } - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -25623,7 +25717,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 === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -25648,32 +25742,32 @@ var ts; return "__constructor" /* Constructor */; case 163 /* FunctionType */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return "__call" /* Call */; case 164 /* ConstructorType */: case 159 /* ConstructSignature */: return "__new" /* New */; case 160 /* IndexSignature */: return "__index" /* Index */; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); 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 === 284 /* 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 === 287 /* 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; @@ -25767,7 +25861,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 === 249 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 252 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -25792,7 +25886,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -25859,7 +25953,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 !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -25904,7 +25998,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -25953,8 +26047,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -25986,77 +26080,78 @@ var ts; return; } switch (node.kind) { - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: bindWhileStatement(node); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: bindDoStatement(node); break; - case 220 /* ForStatement */: + case 223 /* ForStatement */: bindForStatement(node); break; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: bindIfStatement(node); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: bindTryStatement(node); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: bindSwitchStatement(node); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: bindCaseBlock(node); break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: bindCaseClause(node); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: bindLabeledStatement(node); break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: bindCallExpressionFlow(node); break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 274 /* SourceFile */: + case 277 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213 /* Block */: - case 240 /* ModuleBlock */: + } + case 216 /* Block */: + case 243 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -26069,15 +26164,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return hasNarrowableArgument(expr); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -26086,7 +26181,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -26097,7 +26192,7 @@ var ts; } } } - if (expr.expression.kind === 185 /* PropertyAccessExpression */ && + if (expr.expression.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -26130,9 +26225,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -26210,33 +26305,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return parent.expression === node; - case 220 /* ForStatement */: - case 201 /* ConditionalExpression */: + case 223 /* ForStatement */: + case 203 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191 /* ParenthesizedExpression */) { + if (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 /* ParenthesizedExpression */ || - node.parent.kind === 198 /* PrefixUnaryExpression */ && + while (node.parent.kind === 193 /* ParenthesizedExpression */ || + node.parent.kind === 200 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -26278,7 +26373,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -26312,13 +26407,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222 /* ForOfStatement */) { + if (node.kind === 225 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233 /* VariableDeclarationList */) { + if (node.initializer.kind !== 236 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -26340,7 +26435,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225 /* ReturnStatement */) { + if (node.kind === 228 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -26360,7 +26455,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -26456,7 +26551,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* 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; @@ -26524,14 +26619,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -26542,10 +26637,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183 /* ArrayLiteralExpression */) { + else if (node.kind === 185 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204 /* SpreadElement */) { + if (e.kind === 206 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -26553,16 +26648,16 @@ var ts; } } } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270 /* PropertyAssignment */) { + if (p.kind === 273 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271 /* ShorthandPropertyAssignment */) { + else if (p.kind === 274 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272 /* SpreadAssignment */) { + else if (p.kind === 275 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -26618,7 +26713,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26629,7 +26724,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -26676,10 +26771,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 === 191 /* ParenthesizedExpression */) { + while (expr.kind === 193 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { + if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -26687,7 +26782,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26696,21 +26791,21 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 266 /* JsxAttributes */: return 1 /* IsContainer */; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 179 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -26718,32 +26813,32 @@ var ts; } // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: - case 284 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: case 163 /* FunctionType */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 269 /* CatchClause */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 241 /* CaseBlock */: + case 272 /* CatchClause */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 244 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 213 /* Block */: + case 216 /* 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 @@ -26776,20 +26871,20 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 184 /* ObjectLiteralExpression */: - case 236 /* InterfaceDeclaration */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 186 /* ObjectLiteralExpression */: + case 239 /* InterfaceDeclaration */: + case 266 /* 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 @@ -26800,21 +26895,21 @@ var ts; case 164 /* ConstructorType */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 288 /* JSDocSignature */: + case 291 /* 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 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 287 /* JSDocFunctionType */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 240 /* TypeAliasDeclaration */: + case 179 /* 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 @@ -26835,11 +26930,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { + var body = node.kind === 277 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { + if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { return true; } } @@ -26923,7 +27018,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 === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -26935,7 +27030,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 === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -26967,10 +27062,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -27111,8 +27206,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 274 /* SourceFile */ && - blockScopeContainer.kind !== 239 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 277 /* SourceFile */ && + blockScopeContainer.kind !== 242 /* 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. @@ -27208,7 +27303,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1 /* EndOfFileToken */) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -27266,11 +27365,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -27278,7 +27377,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -27306,19 +27405,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return checkStrictModeCatchClause(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkStrictModeWithStatement(node); - case 174 /* ThisType */: + case 176 /* ThisType */: seenThisKeyword = true; return; case 161 /* TypePredicate */: @@ -27327,18 +27426,18 @@ var ts; return bindTypeParameter(node); case 149 /* Parameter */: return bindParameter(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); case 158 /* CallSignature */: case 159 /* ConstructSignature */: @@ -27351,7 +27450,7 @@ var ts; // 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -27360,83 +27459,83 @@ var ts; case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 177 /* MappedType */: + case 290 /* JSDocTypeLiteral */: + case 179 /* MappedType */: return bindAnonymousTypeWorker(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return bindFunctionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return bindJsxAttributes(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return bindImportClause(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return bindExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return bindExportAssignment(node); - case 274 /* SourceFile */: + case 277 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213 /* Block */: + case 216 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 293 /* JSDocParameterTag */: - if (node.parent.kind === 288 /* JSDocSignature */) { + case 296 /* JSDocParameterTag */: + if (node.parent.kind === 291 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { break; } // falls through - case 299 /* JSDocPropertyTag */: + case 302 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -27468,7 +27567,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 /* 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 @@ -27482,7 +27581,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274 /* SourceFile */) { + if (node.parent.kind !== 277 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -27567,8 +27666,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 */) { @@ -27595,7 +27694,7 @@ var ts; 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 274 /* SourceFile */: + case 277 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -27607,7 +27706,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -27664,9 +27763,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + : propertyAccess.parent.parent.kind === 277 /* SourceFile */; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; @@ -27760,7 +27859,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -27793,7 +27892,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); } @@ -27823,7 +27922,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { + if (node.kind === 296 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -27900,7 +27999,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 172 /* InferType */) { + else if (node.parent.kind === 174 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -27928,13 +28027,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || // report error on class declarations - node.kind === 235 /* ClassDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -27991,43 +28090,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); @@ -28038,11 +28137,11 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -28094,12 +28193,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* 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 === 183 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -28148,8 +28247,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 === 208 /* AsExpression */ - || expressionKind === 190 /* TypeAssertionExpression */) { + if (expressionKind === 210 /* AsExpression */ + || expressionKind === 192 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -28526,13 +28625,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -28543,25 +28642,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 209 /* NonNullExpression */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 211 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: case 10 /* JsxText */: - case 258 /* JsxClosingElement */: - case 259 /* JsxFragment */: - case 260 /* JsxOpeningFragment */: - case 261 /* JsxClosingFragment */: - case 262 /* JsxAttribute */: - case 263 /* JsxAttributes */: - case 264 /* JsxSpreadAttribute */: - case 265 /* JsxExpression */: + case 261 /* JsxClosingElement */: + case 262 /* JsxFragment */: + case 263 /* JsxOpeningFragment */: + case 264 /* JsxClosingFragment */: + case 265 /* JsxAttribute */: + case 266 /* JsxAttributes */: + case 267 /* JsxSpreadAttribute */: + case 268 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -28569,11 +28668,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: - case 271 /* ShorthandPropertyAssignment */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 274 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -28587,14 +28686,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 222 /* ForOfStatement */: + case 225 /* 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 203 /* YieldExpression */: + case 205 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -28621,19 +28720,21 @@ var ts; 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 */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 174 /* InferType */: + case 175 /* ParenthesizedType */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: + case 245 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; @@ -28655,10 +28756,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -28670,18 +28771,18 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; @@ -28691,7 +28792,7 @@ var ts; // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -28709,8 +28810,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 183 /* ArrayLiteralExpression */: - case 188 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: + case 190 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -28718,26 +28819,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -28753,27 +28854,27 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 183 /* ArrayLiteralExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return 942011713 /* ClassExcludes */; case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; @@ -28795,24 +28896,24 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 269 /* CatchClause */: + case 272 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: - case 191 /* ParenthesizedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: + case 193 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -29101,6 +29202,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -29174,7 +29276,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -29272,6 +29373,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -29330,7 +29432,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -29387,6 +29489,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; /** @@ -29600,143 +29703,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - 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) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - 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)); // 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)); // TODO: GH#18217 - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896 /* TypeParameters */, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - 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)] : []; // 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)); })); // TODO: GH#18217 - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - 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)); // TODO: GH#18217 - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -29774,6 +29740,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -29899,22 +29890,57 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { - var message_2 = target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */ + var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); + var isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 /* LessThan */ ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -29989,7 +30015,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -30047,17 +30073,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 182 /* BindingElement */) { + if (declaration.kind === 184 /* 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, 182 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 184 /* 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, 232 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235 /* VariableDeclaration */), usage); } - else if (declaration.kind === 232 /* VariableDeclaration */) { + else if (declaration.kind === 235 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -30075,12 +30101,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 === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* 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 === 249 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 252 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -30088,9 +30114,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214 /* VariableStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 217 /* VariableStatement */: + case 223 /* ForStatement */: + case 225 /* 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)) { @@ -30162,7 +30188,7 @@ 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 !== 286 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -30182,7 +30208,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171 /* ConditionalType */) { + else if (location.kind === 173 /* 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; @@ -30196,14 +30222,14 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 277 /* 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 */)) { @@ -30227,7 +30253,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { break; } } @@ -30241,7 +30267,7 @@ var ts; } } break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -30264,9 +30290,9 @@ var ts; } } break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -30282,7 +30308,7 @@ var ts; } break loop; } - if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -30290,7 +30316,7 @@ var ts; } } break; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* 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; @@ -30312,7 +30338,7 @@ var ts; // case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* 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); @@ -30325,14 +30351,14 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -30367,8 +30393,8 @@ var ts; location = location.parent; } break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -30387,7 +30413,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -30461,7 +30487,7 @@ 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 === 242 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 245 /* 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 } } @@ -30470,12 +30496,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 239 /* ModuleDeclaration */: // For `namespace N { N; }` + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -30543,9 +30569,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -30609,18 +30635,26 @@ 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 === 238 /* EnumDeclaration */) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32 /* Class */) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256 /* RegularEnum */) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -30633,13 +30667,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 245 /* ImportClause */: + case 248 /* ImportClause */: return node.parent; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return node.parent.parent; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -30649,7 +30683,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -30837,20 +30871,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 249 /* ExportAssignment */: - case 200 /* BinaryExpression */: + case 252 /* ExportAssignment */: + case 202 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -30911,11 +30945,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 252 /* ExportSpecifier */) { + else if (node.kind === 255 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -30943,7 +30977,7 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -30967,7 +31001,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -31132,10 +31166,19 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages( - /*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)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages( + /*details*/ undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : 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)) + : undefined; 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)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -31161,7 +31204,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -31394,6 +31437,12 @@ var ts; var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -31412,25 +31461,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -31446,12 +31489,12 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -31548,7 +31591,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, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -31660,10 +31703,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -31716,8 +31759,8 @@ var ts; // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || - entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || + entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -31799,64 +31842,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; // TODO: GH#18217 + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -31864,6 +31876,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -31981,7 +31995,7 @@ var ts; 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 & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -32050,7 +32064,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 === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -32088,7 +32102,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; + return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -32136,8 +32150,15 @@ var ts; } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -32351,7 +32372,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 === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -32405,7 +32426,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -32413,7 +32434,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); 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 isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -32422,7 +32443,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; + var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -32432,7 +32454,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 === 182 /* BindingElement */) { + if (clone.kind === 184 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -32516,17 +32538,49 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + 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, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= 16777216 /* InInitialEntityName */; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216 /* InInitialEntityName */; var isTypeOf = meaning === 67216319 /* Value */; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -32700,8 +32754,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 !== 173 /* ParenthesizedType */; }); - if (node.kind === 237 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); + if (node.kind === 240 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -32709,11 +32763,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 /* ModuleBlock */ && + node.parent.kind === 243 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -32733,42 +32787,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 - var file = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); - if (!file || !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); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205 /* ClassExpression */: - return "(Anonymous class)"; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - return "(Anonymous function)"; + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + context.encounteredError = true; + } + return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -32793,27 +32827,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* 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 182 /* BindingElement */: + case 184 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 232 /* VariableDeclaration */: + case 235 /* 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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 234 /* FunctionDeclaration */: - case 238 /* EnumDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 241 /* EnumDeclaration */: + case 246 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -32821,7 +32855,7 @@ 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 !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -32843,31 +32877,31 @@ var ts; case 158 /* CallSignature */: case 160 /* IndexSignature */: case 149 /* Parameter */: - case 240 /* ModuleBlock */: + case 243 /* 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 */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 175 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: return false; // Type parameters are always visible case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 274 /* SourceFile */: - case 242 /* NamespaceExportDeclaration */: + case 277 /* SourceFile */: + case 245 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return false; default: return false; @@ -32876,10 +32910,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 252 /* ExportSpecifier */) { + else if (node.parent.kind === 255 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -32975,12 +33009,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232 /* VariableDeclaration */: - case 233 /* VariableDeclarationList */: - case 248 /* ImportSpecifier */: - case 247 /* NamedImports */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 235 /* VariableDeclaration */: + case 236 /* VariableDeclarationList */: + case 251 /* ImportSpecifier */: + case 250 /* NamedImports */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: return false; default: return true; @@ -33057,7 +33091,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180 /* ObjectBindingPattern */) { + if (pattern.kind === 182 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -33127,22 +33161,27 @@ var ts; // 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(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); + // If the parent is a tuple type, the rest element has an array type with a union of the + // remaining tuple element types. Otherwise, the rest element has an array type with same + // element type as the parent type. + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -33153,7 +33192,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2 /* Subtype */) : type; } @@ -33170,7 +33209,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -33180,11 +33219,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 === 221 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* 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, @@ -33203,7 +33242,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 /* 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 @@ -33275,20 +33314,20 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : - declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : 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 === 155 /* Constructor */ || - thisContainer.kind === 234 /* FunctionDeclaration */ || - (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 /* FunctionDeclaration */ || + (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -33309,7 +33348,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { // If we don't have an explicit JSDoc type, get the type from the expression. var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 /* Anonymous */ && @@ -33391,7 +33430,7 @@ var ts; // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -33436,12 +33475,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { 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. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -33458,7 +33498,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 /* ObjectBindingPattern */ + return pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -33527,7 +33567,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 === 249 /* ExportAssignment */) { + if (declaration.kind === 252 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -33731,8 +33771,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 202 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 187 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 202 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -33869,35 +33909,35 @@ var ts; return undefined; } switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 153 /* MethodSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 177 /* MappedType */: - case 171 /* ConditionalType */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 179 /* MappedType */: + case 173 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177 /* MappedType */) { + if (node.kind === 179 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171 /* ConditionalType */) { + else if (node.kind === 173 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && + (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -33905,7 +33945,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, 236 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -33914,9 +33954,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 235 /* ClassDeclaration */ || - node.kind === 205 /* ClassExpression */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || + node.kind === 207 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -33950,15 +33990,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - // Prefer an @augments tag because it may have type parameters. - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -33981,7 +34013,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -34014,7 +34046,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { if (type.symbol.flags & 32 /* Class */) { @@ -34077,7 +34109,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; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -34102,7 +34134,7 @@ var ts; 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 === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -34138,7 +34170,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */) { + if (declaration.kind === 239 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -34196,7 +34228,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -34223,7 +34255,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 200 /* BinaryExpression */) { + else if (expr.kind === 202 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -34237,12 +34269,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* 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 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -34256,7 +34288,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -34283,7 +34315,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 @@ -34373,7 +34405,7 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 178 /* LiteralType */: + case 180 /* LiteralType */: return true; case 167 /* ArrayType */: return isThislessType(node.elementType); @@ -34753,6 +34785,28 @@ var ts; return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 /* RestParameter */ : + i >= minLength_1 ? 4096 /* OptionalParameter */ : 0; + var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); @@ -34930,6 +34984,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); @@ -34938,6 +34993,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); @@ -35096,7 +35152,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 175 /* TypeOperator */ && + return constraintDeclaration.kind === 177 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -35216,6 +35272,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144 /* Union */)) { @@ -35673,10 +35740,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 === 283 /* JSDocOptionalType */ + node.type && node.type.kind === 286 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -35695,7 +35762,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -35710,7 +35777,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -35805,7 +35872,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178 /* LiteralType */) { + if (type && type.kind === 180 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -35853,9 +35920,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 8192 /* RestParameter */); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { // Replace the last parameter with a rest parameter. parameters.pop(); @@ -35961,9 +36027,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -36006,16 +36072,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1 /* Number */) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -36117,32 +36180,40 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - // When an 'infer T' declaration is immediately contained in a type reference node - // (such as 'Foo'), T's constraint is inferred from the constraint of the - // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are - // present, we form an intersection of the inferred constraint types. - if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - // Type parameter constraints can reference other type parameters so - // constraints need to be instantiated. If instantiation produces the - // type parameter itself, we discard that inference. For example, in - // type Foo = [T, U]; - // type Bar = T extends Foo ? Foo : T; - // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174 /* InferType */) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162 /* TypeReference */) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + // When an 'infer T' declaration is immediately contained in a rest parameter + // declaration, we infer an 'unknown[]' constraint. + else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -36237,7 +36308,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 !== 290 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 293 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -36296,7 +36367,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -36389,9 +36460,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -36503,9 +36574,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return declaration; } } @@ -36626,18 +36697,26 @@ var ts; // // Note that the generic type created by this function has no symbol associated with it. The same // is true for each of the synthesized type parameters. - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536 /* TypeParameter */); - typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + if (i < maxLength) { + var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4 /* Property */, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; @@ -36655,21 +36734,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -37063,7 +37168,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -37128,7 +37233,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -37148,6 +37253,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { @@ -37158,7 +37269,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* 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))) { @@ -37175,14 +37286,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* 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)); } @@ -37288,7 +37407,7 @@ 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 === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -37428,7 +37547,7 @@ var ts; return true; } while (node) { - if (node.kind === 171 /* ConditionalType */) { + if (node.kind === 173 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -37526,7 +37645,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } 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); + var errorMessage = 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_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -37732,7 +37854,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -37751,8 +37873,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return anyType; case 142 /* UnknownKeyword */: return unknownType; @@ -37774,16 +37896,16 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 162 /* TypeReference */: return getTypeFromTypeReference(node); case 161 /* TypePredicate */: return booleanType; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); @@ -37791,38 +37913,41 @@ var ts; return getTypeFromArrayTypeNode(node); case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return getTypeFromOptionalTypeNode(node); + case 171 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 173 /* ParenthesizedType */: - case 282 /* JSDocNonNullableType */: - case 278 /* JSDocTypeExpression */: + case 175 /* ParenthesizedType */: + case 170 /* RestType */: + case 285 /* JSDocNonNullableType */: + case 281 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 172 /* InferType */: + case 174 /* InferType */: return getTypeFromInferTypeNode(node); - case 179 /* ImportType */: + case 181 /* 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 @@ -37971,7 +38096,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | (ts.getCheckFlags(symbol) & 1024 /* Late */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (1024 /* Late */ | 4096 /* OptionalParameter */ | 8192 /* RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -37982,11 +38107,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -38051,14 +38171,14 @@ 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 === 213 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -38196,32 +38316,32 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive); - case 262 /* JsxAttribute */: { + case 265 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265 /* JsxExpression */: { + case 268 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -38238,7 +38358,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* 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); @@ -38248,7 +38368,7 @@ var ts; } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 213 /* Block */ ? false : isContextSensitive(body); + return body.kind === 216 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -38318,8 +38438,206 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268 /* JsxExpression */: + case 193 /* ParenthesizedExpression */: + return elaborateError(node.expression, source, target); + case 202 /* BinaryExpression */: + switch (node.operatorToken.kind) { + case 58 /* EqualsToken */: + case 26 /* CommaToken */: + return elaborateError(node.right, source, target); + } + break; + case 186 /* ObjectLiteralExpression */: + return elaborateObjectLiteral(node, source, target); + case 185 /* ArrayLiteralExpression */: + return elaborateArrayLiteral(node, source, target); + case 266 /* JsxAttributes */: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator, source, target) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + var resultObj = {}; + // Use the expression type, if available + var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + getIndexInfoOfType(target, 0 /* String */) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3 /*break*/, 3]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2 /*return*/]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3 /*break*/, 4]; + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3 /*break*/, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3 /*break*/, 3]; + nameType = getLiteralType(i); + return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3 /*break*/, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 32768 /* Never */)) { + return [3 /*break*/, 7]; + } + _b = prop.kind; + switch (_b) { + case 157 /* SetAccessor */: return [3 /*break*/, 2]; + case 156 /* GetAccessor */: return [3 /*break*/, 2]; + case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + } + return [3 /*break*/, 6]; + case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3 /*break*/, 7]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3 /*break*/, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** * This is *not* a bi-directional relationship. @@ -38340,13 +38658,20 @@ var ts; if (source === target) { return -1 /* True */; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0 /* False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0 /* False */; + } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; @@ -38367,14 +38692,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -38393,7 +38715,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0 /* False */; } @@ -38468,30 +38790,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - // If both have rest parameters, get the max and add 1 to - // compensate for the rest parameter. - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - // Return the count for whichever signature doesn't have rest parameters. - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -38512,11 +38810,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { + return relation === 1 /* Succeeded */; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, false); + enumRelation.set(id, 3 /* FailedAndReported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -38527,13 +38825,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); + enumRelation.set(id, 3 /* FailedAndReported */); + } + else { + enumRelation.set(id, 2 /* Failed */); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1 /* Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -38624,7 +38925,7 @@ var ts; * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -38654,12 +38955,16 @@ var ts; var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); // Cause the error to appear with the error that triggered it + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); // Cause the error to appear with the error that triggered it } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); // TODO: GH#18217 + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { @@ -38741,6 +39046,22 @@ var ts; if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); + if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + target = nullStrippedTarget; + } + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; @@ -38992,11 +39313,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } return 0 /* False */; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072 /* Object */) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4 /* Reference */) { + return source.target === target.target; + } + if (overlapObjFlags & 16 /* Anonymous */) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { var match; @@ -39128,9 +39467,8 @@ var ts; var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { - // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported - // failure and continue computing the relation such that errors get reported. - relation.set(id, 3 /* FailedAndReported */); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -39417,7 +39755,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -39440,6 +39778,33 @@ var ts; } } var result = -1 /* True */; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0 /* False */; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0 /* False */; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0 /* False */; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -39961,20 +40326,26 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); // A source signature matches a target signature if the two signatures have the same number of required, // optional, and rest parameters. - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } // A source signature partially matches a target signature if the target signature has no fewer required // parameters and no more overall parameters than the source signature (where a signature with a rest // parameter is always considered to have more overall parameters than one without). - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -40016,10 +40387,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0 /* False */; @@ -40039,9 +40410,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -40091,7 +40459,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); @@ -40138,6 +40511,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -40197,7 +40576,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -40410,7 +40789,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -40420,23 +40799,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* 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 177 /* MappedType */: + case 179 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -40453,24 +40832,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -40609,10 +40986,14 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - // Two tuple types with different arity are definitely unrelated. + // Two tuple types with incompatible arities are definitely unrelated. // Two object types that each have a property that is unmatched in the other are definitely unrelated. - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) && !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false); } function getTypeFromInference(inference) { @@ -40895,12 +41276,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -41015,17 +41417,14 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + // If we have contravariant inferences we find the best common subtype and treat + // that as a single covariant candidate. + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { 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 & 32768 /* Never */ && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - // We only have contravariant inferences, infer the best common subtype of those - inferredType = getContravariantInference(inference); } else if (context.flags & 2 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -41102,13 +41501,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 185 /* PropertyAccessExpression */) { + if (node.kind === 187 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182 /* BindingElement */) { + if (node.kind === 184 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -41117,7 +41516,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180 /* ObjectBindingPattern */) { + if (parent.kind === 182 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: @@ -41140,26 +41539,26 @@ var ts; switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && + (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 185 /* PropertyAccessExpression */: - return target.kind === 185 /* PropertyAccessExpression */ && + case 187 /* PropertyAccessExpression */: + return target.kind === 187 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182 /* BindingElement */: - if (target.kind !== 185 /* PropertyAccessExpression */) + case 184 /* BindingElement */: + if (target.kind !== 187 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232 /* VariableDeclaration */) { + if (source.parent.parent.kind === 235 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -41167,7 +41566,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185 /* PropertyAccessExpression */) { + while (source.kind === 187 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -41180,7 +41579,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 === 185 /* PropertyAccessExpression */ && + return target.kind === 187 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -41188,7 +41587,7 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185 /* PropertyAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -41232,7 +41631,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -41358,7 +41757,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; } @@ -41366,15 +41765,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -41391,21 +41790,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return stringType; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return undefinedType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -41413,7 +41812,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 /* ObjectBindingPattern */ ? + var type = pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -41431,35 +41830,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221 /* ForInStatement */) { + if (node.parent.parent.kind === 224 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.parent.kind === 225 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 /* VariableDeclaration */ ? + return node.kind === 235 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? + return node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 /* VariableDeclaration */ && node.initializer && + return node.kind === 235 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && + node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -41471,13 +41870,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - 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 ? + return parent.kind === 193 /* ParenthesizedExpression */ || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -41640,11 +42039,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - 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 */ && + var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 200 /* BinaryExpression */ && + parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -41692,7 +42091,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 === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -41763,7 +42162,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 !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 187 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -41819,7 +42218,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 /* CallExpression */ ? + var expr = node.kind === 189 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -41827,7 +42226,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -41992,7 +42391,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 /* PropertyAccessExpression */ && + return expr.kind === 187 /* PropertyAccessExpression */ && computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -42043,10 +42442,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 === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -42261,7 +42660,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -42281,15 +42680,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -42325,8 +42724,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 /* ModuleBlock */ || - node.kind === 274 /* SourceFile */ || + node.kind === 243 /* ModuleBlock */ || + node.kind === 277 /* SourceFile */ || node.kind === 152 /* PropertyDeclaration */; }); } @@ -42372,10 +42771,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - 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; + return parent.kind === 187 /* PropertyAccessExpression */ || + parent.kind === 189 /* CallExpression */ && parent.expression === node || + parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); @@ -42409,7 +42808,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 */)) { @@ -42430,7 +42829,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 === 235 /* ClassDeclaration */ + if (declaration.kind === 238 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -42442,12 +42841,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205 /* ClassExpression */) { + else if (declaration.kind === 207 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 274 /* SourceFile */) { + while (container.kind !== 277 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; @@ -42497,23 +42896,23 @@ var ts; 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); + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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 === 192 /* FunctionExpression */ || - flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 /* FunctionExpression */ || + flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // 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 || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || 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 || + isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || + node.parent.kind === 211 /* NonNullExpression */ || + declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -42544,7 +42943,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -42569,8 +42968,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 === 220 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && + if (container.kind === 223 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -42584,7 +42983,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 191 /* ParenthesizedExpression */) { + while (current.parent.kind === 193 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -42592,7 +42991,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -42650,7 +43049,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); // If a containing class does not have extends clause or the class extends null // skip checking whether super statement is called before "this" accessing. if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -42677,17 +43076,17 @@ var ts; 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 === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 238 /* EnumDeclaration */: + case 241 /* 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; @@ -42725,8 +43124,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 === 192 /* FunctionExpression */ && - container.parent.kind === 200 /* BinaryExpression */ && + if (container.kind === 194 /* FunctionExpression */ && + container.parent.kind === 202 /* 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 @@ -42757,7 +43156,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -42774,12 +43173,12 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 /* 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 === 193 /* ArrowFunction */) { + while (container && container.kind === 195 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -42799,7 +43198,7 @@ var ts; 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 === 184 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -42887,7 +43286,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184 /* ObjectLiteralExpression */) { + if (container.parent.kind === 186 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -42899,7 +43298,7 @@ var ts; } // at this point the only legal case for parent is ClassLikeDeclaration var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -42931,7 +43330,7 @@ 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 === 184 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 154 /* MethodDeclaration */ || container.kind === 153 /* MethodSignature */ || @@ -42955,8 +43354,8 @@ var ts; function getContainingObjectLiteral(func) { 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 : + func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -42968,7 +43367,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193 /* ArrowFunction */) { + if (func.kind === 195 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -42995,7 +43394,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270 /* PropertyAssignment */) { + if (literal.parent.kind !== 273 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -43009,9 +43408,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 === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { + if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* 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)) { @@ -43034,27 +43433,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. @@ -43064,10 +43460,8 @@ var ts; return getTypeAtPosition(contextualSignature, indexOfParameter); } // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -43098,7 +43492,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182 /* BindingElement */) { + if (parentDeclaration.kind !== 184 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -43180,7 +43574,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189 /* TaggedTemplateExpression */) { + if (template.parent.kind === 191 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -43228,8 +43622,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504 /* StructuredType */) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, /*noReductions*/ true); } function getIndexTypeOfContextualType(type, kind) { @@ -43258,8 +43663,8 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -43325,8 +43730,8 @@ var ts; case 95 /* NullKeyword */: case 71 /* Identifier */: return true; - case 185 /* PropertyAccessExpression */: - case 191 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 193 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -43345,14 +43750,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270 /* PropertyAssignment */) + if (prop.kind !== 273 /* PropertyAssignment */) continue; 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); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine @@ -43393,52 +43798,52 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 193 /* ArrowFunction */: - case 225 /* ReturnStatement */: + case 195 /* ArrowFunction */: + case 228 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 183 /* ArrayLiteralExpression */: { + case 185 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 211 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); + case 214 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191 /* ParenthesizedExpression */: { + case 193 /* 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 265 /* JsxExpression */: + case 268 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -43512,6 +43917,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -43522,8 +43928,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) @@ -43539,7 +43961,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -43584,11 +44007,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; + return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -43660,18 +44082,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 182 /* BindingElement */ && !!node.initializer) || - (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 184 /* BindingElement */ && !!node.initializer) || + (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -43696,13 +44119,17 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; + if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } @@ -43710,28 +44137,30 @@ 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 === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - 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); + else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { + if (e.kind !== 208 /* OmittedExpression */) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2 /* Subtype */); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2 /* Subtype */) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -43816,7 +44245,7 @@ var ts; var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -43830,11 +44259,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 /* PropertyAssignment */ || - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 273 /* PropertyAssignment */ || + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -43855,8 +44284,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 === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -43881,7 +44310,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272 /* SpreadAssignment */) { + else if (memberDecl.kind === 275 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -43975,13 +44404,16 @@ var ts; type.flags & 131072 /* Object */ && !isGenericMappedType(type) || type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { + function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -43989,6 +44421,9 @@ var ts; else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -44011,16 +44446,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - // TODO (yuisu): comment - switch (tagName.kind) { - case 185 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: - return false; - case 71 /* Identifier */: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -44063,7 +44489,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -44086,7 +44512,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 255 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 /* 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); @@ -44247,12 +44673,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -44289,6 +44727,10 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928 /* Type */); + } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -44695,7 +45137,7 @@ var ts; // sourceAttributesType is a type of an attributes properties. // i.e
// attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. @@ -44716,31 +45158,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -44787,9 +45205,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? + var errorNode = node.kind === 187 /* PropertyAccessExpression */ || node.kind === 235 /* VariableDeclaration */ ? node.name : - node.kind === 179 /* ImportType */ ? + node.kind === 181 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -44959,7 +45377,7 @@ 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 !== 185 /* PropertyAccessExpression */ || + if (node.kind !== 187 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; @@ -44991,16 +45409,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + else if (valueDeclaration.kind === 238 /* 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)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -45008,7 +45431,7 @@ var ts; switch (node.kind) { case 152 /* PropertyDeclaration */: return true; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -45064,13 +45487,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319 /* Value */); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319 /* Value */); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -45129,16 +45558,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179 /* ImportType */: + case 181 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -45172,7 +45601,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer.kind === 236 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -45201,7 +45630,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 /* ForInStatement */ && + if (node.kind === 224 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -45219,7 +45648,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 190 /* 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); @@ -45286,7 +45715,7 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (node.kind !== 150 /* Decorator */) { @@ -45352,14 +45781,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204 /* SpreadElement */) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -45371,12 +45797,12 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* 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 = node.typeArguments; - if (node.template.kind === 202 /* TemplateExpression */) { + if (node.template.kind === 204 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -45398,8 +45824,8 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 188 /* NewExpression */); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190 /* NewExpression */); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. @@ -45412,15 +45838,14 @@ var ts; } // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -45445,9 +45870,10 @@ var ts; // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1 /* InferUnionTypes */, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8 /* ReturnType */); @@ -45497,7 +45923,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -45512,11 +45938,13 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; 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 !== 206 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -45530,6 +45958,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) @@ -45547,6 +45979,35 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + // We are inferring from a spread expression in the last argument position, i.e. both the parameter + // and the argument are ...x forms. + return arg.kind === 213 /* SyntheticExpression */ ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -45606,7 +46067,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 190 /* 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. @@ -45620,24 +46081,32 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; 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 !== 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. - // In that case, we should check the argument. - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { + if (i === restIndex && (restType.flags & 65536 /* TypeParameter */ || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, /*context*/ undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + // 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. + // In that case, we should check the argument. + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } @@ -45647,9 +46116,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { + if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { return callee.expression; } } @@ -45664,10 +46133,10 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [undefined]; // TODO: GH#18217 - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -45684,7 +46153,28 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + // We have a spread argument in the last position and no other spread arguments. If the type + // of the argument is a tuple type, spread the tuple elements into the argument list. We can + // call checkExpressionCached because spread expressions never have a contextual type. + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213 /* SyntheticExpression */, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } /** @@ -45703,8 +46193,8 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; case 152 /* PropertyDeclaration */: @@ -45749,7 +46239,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* 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); @@ -45794,7 +46284,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -45849,7 +46339,7 @@ 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 === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -45898,7 +46388,7 @@ var ts; if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -45911,7 +46401,7 @@ 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 === 150 /* Decorator */ || - (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { + (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -45924,7 +46414,7 @@ var ts; // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -45944,7 +46434,7 @@ 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 === 189 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -46019,7 +46509,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 === 187 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 /* 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 @@ -46066,10 +46556,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -46184,11 +46674,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -46204,7 +46695,7 @@ var ts; 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)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -46383,8 +46874,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -46410,8 +46900,8 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -46487,16 +46977,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -46572,7 +47062,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -46586,7 +47077,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185 /* PropertyAccessExpression */) { + while (parent && parent.kind === 187 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -46618,7 +47109,7 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 188 /* NewExpression */) { + if (node.kind === 190 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 /* Constructor */ && @@ -46692,7 +47183,7 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -46749,9 +47240,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 234 /* FunctionDeclaration */ + ? 237 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 232 /* VariableDeclaration */ + ? 235 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -46829,10 +47320,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1 /* Number */) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536 /* TypeParameter */) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -46871,11 +47459,11 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -46940,7 +47528,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213 /* Block */) { + if (func.body.kind !== 216 /* 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 @@ -47029,7 +47617,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -47054,7 +47642,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -47097,11 +47685,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; case 154 /* MethodDeclaration */: - return func.parent.kind === 184 /* ObjectLiteralExpression */; + return func.parent.kind === 186 /* ObjectLiteralExpression */; default: return false; } @@ -47125,7 +47713,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -47165,7 +47753,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -47226,7 +47814,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213 /* Block */) { + if (node.body.kind === 216 /* Block */) { checkSourceElement(node.body); } else { @@ -47239,10 +47827,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -47272,7 +47860,7 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && + (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* 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); @@ -47289,13 +47877,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* 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 === 246 /* NamespaceImport */; + return !!declaration && declaration.kind === 249 /* NamespaceImport */; } } } @@ -47304,7 +47892,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 !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -47313,7 +47901,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { + if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -47490,7 +48078,7 @@ 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 === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { var name = property.name; if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); @@ -47505,7 +48093,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 274 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -47517,7 +48105,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 === 272 /* SpreadAssignment */) { + else if (property.kind === 275 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -47552,27 +48140,23 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206 /* OmittedExpression */) { - if (element.kind !== 204 /* SpreadElement */) { + if (element.kind !== 208 /* OmittedExpression */) { + if (element.kind !== 206 /* SpreadElement */) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - // We still need to check element expression here because we may need to set appropriate flag on the expression - // such as NodeCheckFlags.LexicalThis on "this"expression. - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -47581,12 +48165,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -47595,7 +48182,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -47611,25 +48198,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184 /* ObjectLiteralExpression */) { + if (target.kind === 186 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183 /* ArrayLiteralExpression */) { + if (target.kind === 185 /* 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 === 272 /* SpreadAssignment */ ? + var error = target.parent.kind === 275 /* 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)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -47647,35 +48234,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 189 /* TaggedTemplateExpression */: - case 202 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - 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 */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 197 /* TypeOfExpression */: + case 211 /* NonNullExpression */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: return true; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -47687,9 +48274,9 @@ var ts; } return false; // Some forms listed here for clarity - 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 + case 198 /* VoidExpression */: // Explicit opt-out + case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -47705,7 +48292,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -47904,7 +48491,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -47925,7 +48512,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34 /* EqualsEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -47982,7 +48585,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' return anyType; @@ -48007,7 +48610,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263 /* JsxAttributes */) { + if (node.kind === 266 /* 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; @@ -48043,7 +48646,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; + return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -48145,7 +48748,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 === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 /* 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) { @@ -48195,8 +48798,8 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 188 /* 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) { @@ -48232,74 +48835,76 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checkCallExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return checkClassExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return checkAssertion(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return checkNonNullAssertion(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return checkMetaProperty(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkDeleteExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return checkVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return checkAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return undefinedWideningType; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return checkYieldExpression(node); - case 265 /* JsxExpression */: + case 213 /* SyntheticExpression */: + return node.type; + case 268 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return checkJsxElement(node, checkMode); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -48328,6 +48933,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 /* Instantiable */ && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -48354,7 +48962,7 @@ var ts; } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -48415,10 +49023,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 158 /* CallSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 163 /* FunctionType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -48439,7 +49047,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 === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { + else if (name.kind === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -48452,7 +49060,7 @@ var ts; checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + else if (node.kind === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -48517,7 +49125,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -48646,7 +49254,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* 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 @@ -48734,7 +49342,7 @@ var ts; // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -48756,7 +49364,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 === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -48907,11 +49515,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170 /* RestType */) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169 /* OptionalType */) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -48925,7 +49550,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 186 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 /* 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)); } @@ -48962,7 +49587,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* 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); @@ -48978,9 +49603,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 !== 236 /* InterfaceDeclaration */ && - n.parent.kind !== 235 /* ClassDeclaration */ && - n.parent.kind !== 205 /* ClassExpression */ && + if (n.parent.kind !== 239 /* InterfaceDeclaration */ && + n.parent.kind !== 238 /* ClassDeclaration */ && + n.parent.kind !== 207 /* 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 @@ -49110,7 +49735,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 /* 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 @@ -49121,7 +49746,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 === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -49250,22 +49875,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 249 /* ExportAssignment */: + case 252 /* 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 */; @@ -49273,17 +49898,17 @@ 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 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 248 /* 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 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 234 /* FunctionDeclaration */: - case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 237 /* FunctionDeclaration */: + case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -49554,7 +50179,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -49617,12 +50242,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -49654,7 +50279,7 @@ var ts; } } return commonEntityName; - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); case 162 /* TypeReference */: return node.typeName; @@ -49687,7 +50312,7 @@ var ts; 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -49776,7 +50401,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -49788,7 +50413,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -49871,27 +50496,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274 /* SourceFile */: - case 239 /* ModuleDeclaration */: - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 242 /* ModuleDeclaration */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -49905,7 +50530,7 @@ var ts; case 159 /* ConstructSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -49918,10 +50543,7 @@ var ts; 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.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -49951,7 +50573,7 @@ var ts; } break; case 160 /* IndexSignature */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: // Can't be private break; default: @@ -49967,7 +50589,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -50002,7 +50624,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -50020,9 +50642,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -50037,7 +50659,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0 /* Local */, unuseds.length === 1 @@ -50055,7 +50677,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -50076,7 +50698,7 @@ var ts; 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)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -50090,22 +50712,22 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; + return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 213 /* Block */) { + if (node.kind === 216 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -50200,7 +50822,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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 /* 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)); } @@ -50215,7 +50837,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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 277 /* 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)); } @@ -50250,7 +50872,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 === 232 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -50262,17 +50884,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 214 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 217 /* 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 === 213 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 240 /* ModuleBlock */ || - container.kind === 239 /* ModuleDeclaration */ || - container.kind === 274 /* SourceFile */); + (container.kind === 216 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 243 /* ModuleBlock */ || + container.kind === 242 /* ModuleDeclaration */ || + container.kind === 277 /* 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 @@ -50298,7 +50920,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 185 /* PropertyAccessExpression */) { + if (n.kind === 187 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -50318,7 +50940,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 182 /* BindingElement */) { + symbol.valueDeclaration.kind === 184 /* 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) { @@ -50371,8 +50993,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182 /* BindingElement */) { - if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 184 /* BindingElement */) { + if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -50393,7 +51015,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -50406,13 +51028,13 @@ var ts; // 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 !== 221 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -50429,8 +51051,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221 /* ForInStatement */) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -50445,7 +51067,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -50455,7 +51077,7 @@ var ts; 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 === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -50470,8 +51092,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || - (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || + (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -50510,7 +51132,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215 /* EmptyStatement */) { + if (node.thenStatement.kind === 218 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -50530,12 +51152,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -50569,14 +51191,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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. @@ -50590,7 +51212,7 @@ var ts; // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -50608,7 +51230,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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); @@ -50622,7 +51244,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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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)) { @@ -50986,7 +51608,7 @@ var ts; } } else if (func.kind === 155 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -51002,7 +51624,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -51035,7 +51657,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 === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -51047,7 +51669,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 269 /* 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. @@ -51076,7 +51698,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -51174,16 +51796,17 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } // perform property check if property or indexer is declared in 'type' // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || + if (propDeclaration && name && + (propDeclaration.kind === 202 /* BinaryExpression */ || + name.kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -51357,7 +51980,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); @@ -51369,6 +51992,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -51435,7 +52062,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -51454,7 +52081,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -51480,7 +52107,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; + return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -51519,7 +52146,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 === 205 /* ClassExpression */) { + if (derivedClassDecl.kind === 207 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -51633,7 +52260,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -51696,7 +52323,7 @@ var ts; } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -51711,7 +52338,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -51738,7 +52365,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -51748,7 +52375,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -51776,7 +52403,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: var identifier = expr; @@ -51784,14 +52411,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* 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 === 185 /* PropertyAccessExpression */) { + if (ex.kind === 187 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -51823,8 +52450,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -51838,7 +52465,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304 /* Ambient */) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -51854,7 +52481,7 @@ var ts; if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -51862,7 +52489,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 !== 238 /* EnumDeclaration */) { + if (declaration.kind !== 241 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -51885,8 +52512,8 @@ var ts; var declarations = symbol.declarations; 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))) && + if ((declaration.kind === 238 /* ClassDeclaration */ || + (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -51949,7 +52576,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, 235 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -51999,23 +52626,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* 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 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -52026,12 +52653,12 @@ var ts; break; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 234 /* FunctionDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -52059,7 +52686,7 @@ var ts; node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -52076,9 +52703,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - 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 */ ? + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -52111,14 +52738,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 === 252 /* ExportSpecifier */ ? + var message = node.kind === 255 /* 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 === 252 /* ExportSpecifier */ + && node.kind === 255 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -52145,7 +52772,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -52169,7 +52796,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -52205,10 +52832,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -52225,7 +52852,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -52254,8 +52881,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 === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -52343,7 +52970,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -52361,10 +52988,10 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -52402,111 +53029,113 @@ var ts; return checkArrayType(node); case 168 /* TupleType */: return checkTupleType(node); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: + case 169 /* OptionalType */: + case 170 /* RestType */: return checkSourceElement(node.type); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return checkTypeOperator(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return checkConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return checkInferType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return checkImportType(node); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 282 /* JSDocNonNullableType */: - case 281 /* JSDocNullableType */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: - case 287 /* JSDocTypeLiteral */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: + case 290 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 278 /* JSDocTypeExpression */: + case 281 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return checkMappedType(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return checkBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return checkVariableStatement(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return checkExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return checkIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return checkDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return checkWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return checkForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return checkForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkForOfStatement(node); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return checkReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return checkSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return checkLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return checkThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return checkTryStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return checkBindingElement(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return checkClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return checkImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return checkExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return checkExportAssignment(node); - case 215 /* EmptyStatement */: - case 231 /* DebuggerStatement */: + case 218 /* EmptyStatement */: + case 234 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -52583,15 +53212,15 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -52600,11 +53229,17 @@ var ts; case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: checkClassExpressionDeferred(node); break; + case 259 /* JsxSelfClosingElement */: + checkJsxSelfClosingElementDeferred(node); + break; + case 258 /* JsxElement */: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -52639,7 +53274,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -52733,13 +53368,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -52747,8 +53382,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* 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. @@ -52757,7 +53392,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -52806,10 +53441,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148 /* TypeParameter */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -52823,10 +53458,10 @@ var ts; return node.parent.kind === 162 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185 /* PropertyAccessExpression */) { + while (node.parent.kind === 187 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 207 /* ExpressionWithTypeArguments */; + return node.parent.kind === 209 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -52857,10 +53492,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -52886,7 +53521,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -52896,7 +53531,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 /* PropertyAccessExpression */ && + entityName.parent.kind === 187 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -52904,7 +53539,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 /* 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); @@ -52914,7 +53549,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, 243 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -52932,7 +53567,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 === 207 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -52948,10 +53583,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293 /* JSDocParameterTag */) { + if (entityName.parent.kind === 296 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 297 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 300 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -52968,12 +53603,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185 /* PropertyAccessExpression */) { + if (entityName.kind === 187 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -52986,7 +53621,7 @@ var ts; var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 262 /* JsxAttribute */) { + else if (entityName.parent.kind === 265 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161 /* TypePredicate */) { @@ -52996,7 +53631,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -53016,8 +53651,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 /* BindingElement */ && - grandParent.kind === 180 /* ObjectBindingPattern */ && + else if (parent.kind === 184 /* BindingElement */ && + grandParent.kind === 182 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -53028,7 +53663,7 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: @@ -53043,7 +53678,7 @@ var ts; return checkExpression(node).symbol; } // falls through - case 174 /* ThisType */: + case 176 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; @@ -53061,7 +53696,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 === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* 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); @@ -53079,14 +53714,14 @@ var ts; case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -53159,28 +53794,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 222 /* ForOfStatement */) { + if (expr.parent.kind === 225 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 200 /* BinaryExpression */) { + if (expr.parent.kind === 202 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 270 /* PropertyAssignment */) { + if (expr.parent.kind === 273 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -53259,7 +53894,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -53315,7 +53950,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* 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. @@ -53370,7 +54005,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 === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -53411,16 +54046,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -53430,7 +54065,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -53511,22 +54146,23 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273 /* EnumMember */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 276 /* EnumMember */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273 /* EnumMember */) { + if (node.kind === 276 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8 /* EnumMember */)) { // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -53664,7 +54300,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } @@ -53761,7 +54397,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; + return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -53773,7 +54409,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 === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -53824,7 +54460,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -53839,12 +54475,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 /* 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, 274 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 277 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -53852,10 +54488,14 @@ var ts; var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); // Initialize global symbol table var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -53929,6 +54569,32 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -54022,7 +54688,7 @@ var ts; } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { + if (node.kind !== 241 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -54042,7 +54708,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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -54065,7 +54731,7 @@ 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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149 /* Parameter */) { @@ -54101,7 +54767,7 @@ 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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149 /* Parameter */) { @@ -54110,8 +54776,8 @@ var ts; flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -54123,13 +54789,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } 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 === 240 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -54139,14 +54805,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 238 /* 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 === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 238 /* 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 */) { @@ -54188,7 +54854,7 @@ var ts; } return false; } - else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -54223,29 +54889,29 @@ var ts; 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 242 /* ModuleDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 149 /* Parameter */: return false; default: - if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return false; } switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 236 /* InterfaceDeclaration */: - case 214 /* VariableStatement */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 217 /* VariableStatement */: + case 240 /* TypeAliasDeclaration */: return true; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -54259,9 +54925,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -54394,7 +55060,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206 /* OmittedExpression */) { + if (arg.kind === 208 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -54475,15 +55141,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 202 /* 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 === 234 /* FunctionDeclaration */ || - node.kind === 192 /* FunctionExpression */ || + ts.Debug.assert(node.kind === 237 /* FunctionDeclaration */ || + node.kind === 194 /* FunctionExpression */ || node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -54507,7 +55173,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 === 272 /* SpreadAssignment */) { + if (prop.kind === 275 /* SpreadAssignment */) { continue; } var name = prop.name; @@ -54515,7 +55181,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 /* 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); @@ -54539,8 +55205,8 @@ 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 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -54590,7 +55256,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 === 264 /* JsxSpreadAttribute */) { + if (attr.kind === 267 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -54600,7 +55266,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -54609,12 +55275,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -54629,20 +55295,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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); @@ -54711,7 +55377,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* 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); @@ -54749,7 +55415,7 @@ var ts; return true; } if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 184 /* ObjectLiteralExpression */) { + if (node.parent.kind === 186 /* 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); @@ -54778,7 +55444,7 @@ var ts; 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 === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* 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 === 166 /* TypeLiteral */) { @@ -54792,11 +55458,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228 /* LabeledStatement */: + case 231 /* 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 === 223 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 226 /* 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); @@ -54804,8 +55470,8 @@ var ts; return false; } break; - case 227 /* SwitchStatement */: - if (node.kind === 224 /* BreakStatement */ && !node.label) { + case 230 /* SwitchStatement */: + if (node.kind === 227 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -54820,13 +55486,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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 === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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); @@ -54839,7 +55505,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 === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { + if (node.name.kind === 183 /* ArrayBindingPattern */ || node.name.kind === 182 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -54853,14 +55519,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { + if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -54871,7 +55537,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -54881,19 +55547,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 /* 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 && !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -54948,15 +55614,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return false; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -54966,7 +55632,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -55033,7 +55699,7 @@ var ts; return true; } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* 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; } @@ -55070,13 +55736,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - 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 */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 240 /* TypeAliasDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 253 /* ExportDeclaration */ || + node.kind === 252 /* ExportAssignment */ || + node.kind === 245 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -55085,7 +55751,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 214 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 217 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -55112,7 +55778,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 === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -55134,10 +55800,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, 178 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -55192,8 +55858,8 @@ var ts; /** 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 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -55201,14 +55867,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245 /* ImportClause */: // For default import - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: // For rename import `x as y` + case 248 /* ImportClause */: // For default import + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* 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 === 248 /* ImportSpecifier */; + return decl.parent.kind === 251 /* ImportSpecifier */; default: return false; } @@ -55224,8 +55890,12 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448 /* Literal */); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -55391,7 +56061,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 /* Node */ | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -55484,10 +56154,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 303 /* CommaListExpression */ ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147 /* ComputedPropertyName */); @@ -55850,14 +56519,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169 /* OptionalType */); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170 /* RestType */); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -55865,7 +56558,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -55884,7 +56577,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171 /* ConditionalType */); + var node = createSynthesizedNode(173 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -55902,7 +56595,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172 /* InferType */); + var node = createSynthesizedNode(174 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -55914,7 +56607,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179 /* ImportType */); + var node = createSynthesizedNode(181 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -55932,7 +56625,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173 /* ParenthesizedType */); + var node = createSynthesizedNode(175 /* ParenthesizedType */); node.type = type; return node; } @@ -55944,11 +56637,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174 /* ThisType */); + return createSynthesizedNode(176 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175 /* TypeOperator */); + var node = createSynthesizedNode(177 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -55959,7 +56652,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176 /* IndexedAccessType */); + var node = createSynthesizedNode(178 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -55973,7 +56666,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177 /* MappedType */); + var node = createSynthesizedNode(179 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -55991,7 +56684,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178 /* LiteralType */); + var node = createSynthesizedNode(180 /* LiteralType */); node.literal = literal; return node; } @@ -56004,7 +56697,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ObjectBindingPattern */); + var node = createSynthesizedNode(182 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56016,7 +56709,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181 /* ArrayBindingPattern */); + var node = createSynthesizedNode(183 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56028,7 +56721,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182 /* BindingElement */); + var node = createSynthesizedNode(184 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -56047,7 +56740,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -56061,7 +56754,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -56075,7 +56768,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185 /* PropertyAccessExpression */); + var node = createSynthesizedNode(187 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -56092,7 +56785,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186 /* ElementAccessExpression */); + var node = createSynthesizedNode(188 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -56106,7 +56799,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* CallExpression */); + var node = createSynthesizedNode(189 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -56122,7 +56815,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188 /* NewExpression */); + var node = createSynthesizedNode(190 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -56138,7 +56831,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -56161,7 +56854,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190 /* TypeAssertionExpression */); + var node = createSynthesizedNode(192 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -56175,7 +56868,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191 /* ParenthesizedExpression */); + var node = createSynthesizedNode(193 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -56187,7 +56880,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192 /* FunctionExpression */); + var node = createSynthesizedNode(194 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -56211,7 +56904,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193 /* ArrowFunction */); + var node = createSynthesizedNode(195 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -56245,7 +56938,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194 /* DeleteExpression */); + var node = createSynthesizedNode(196 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56257,7 +56950,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195 /* TypeOfExpression */); + var node = createSynthesizedNode(197 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56269,7 +56962,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196 /* VoidExpression */); + var node = createSynthesizedNode(198 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56281,7 +56974,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197 /* AwaitExpression */); + var node = createSynthesizedNode(199 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56293,7 +56986,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -56306,7 +56999,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -56319,7 +57012,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200 /* BinaryExpression */); + var node = createSynthesizedNode(202 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -56336,7 +57029,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201 /* ConditionalExpression */); + var node = createSynthesizedNode(203 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -56366,7 +57059,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202 /* TemplateExpression */); + var node = createSynthesizedNode(204 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -56404,7 +57097,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203 /* YieldExpression */); + var node = createSynthesizedNode(205 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -56418,7 +57111,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204 /* SpreadElement */); + var node = createSynthesizedNode(206 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -56430,7 +57123,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205 /* ClassExpression */); + var node = createSynthesizedNode(207 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56451,11 +57144,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206 /* OmittedExpression */); + return createSynthesizedNode(208 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -56469,7 +57162,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208 /* AsExpression */); + var node = createSynthesizedNode(210 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -56483,7 +57176,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209 /* NonNullExpression */); + var node = createSynthesizedNode(211 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -56495,7 +57188,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210 /* MetaProperty */); + var node = createSynthesizedNode(212 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -56509,7 +57202,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211 /* TemplateSpan */); + var node = createSynthesizedNode(214 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -56523,25 +57216,18 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212 /* SemicolonClassElement */); + return createSynthesizedNode(215 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213 /* Block */); + var block = createSynthesizedNode(216 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - /* @internal */ - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216 /* ExpressionStatement */); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -56549,7 +57235,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214 /* VariableStatement */); + var node = createSynthesizedNode(217 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -56564,21 +57250,27 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215 /* EmptyStatement */); + return createSynthesizedNode(218 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + ts.createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217 /* IfStatement */); + var node = createSynthesizedNode(220 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -56594,7 +57286,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218 /* DoStatement */); + var node = createSynthesizedNode(221 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -56608,7 +57300,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219 /* WhileStatement */); + var node = createSynthesizedNode(222 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -56622,7 +57314,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220 /* ForStatement */); + var node = createSynthesizedNode(223 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -56640,7 +57332,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForInStatement */); + var node = createSynthesizedNode(224 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -56656,7 +57348,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222 /* ForOfStatement */); + var node = createSynthesizedNode(225 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -56674,7 +57366,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223 /* ContinueStatement */); + var node = createSynthesizedNode(226 /* ContinueStatement */); node.label = asName(label); return node; } @@ -56686,7 +57378,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224 /* BreakStatement */); + var node = createSynthesizedNode(227 /* BreakStatement */); node.label = asName(label); return node; } @@ -56698,7 +57390,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225 /* ReturnStatement */); + var node = createSynthesizedNode(228 /* ReturnStatement */); node.expression = expression; return node; } @@ -56710,7 +57402,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226 /* WithStatement */); + var node = createSynthesizedNode(229 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -56724,7 +57416,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227 /* SwitchStatement */); + var node = createSynthesizedNode(230 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -56738,7 +57430,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228 /* LabeledStatement */); + var node = createSynthesizedNode(231 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -56752,7 +57444,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229 /* ThrowStatement */); + var node = createSynthesizedNode(232 /* ThrowStatement */); node.expression = expression; return node; } @@ -56764,7 +57456,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230 /* TryStatement */); + var node = createSynthesizedNode(233 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -56780,11 +57472,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231 /* DebuggerStatement */); + return createSynthesizedNode(234 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232 /* VariableDeclaration */); + var node = createSynthesizedNode(235 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -56801,7 +57493,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(233 /* VariableDeclarationList */); + var node = createSynthesizedNode(236 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -56814,7 +57506,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234 /* FunctionDeclaration */); + var node = createSynthesizedNode(237 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -56840,7 +57532,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* ClassDeclaration */); + var node = createSynthesizedNode(238 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56862,7 +57554,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236 /* InterfaceDeclaration */); + var node = createSynthesizedNode(239 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56884,7 +57576,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56904,7 +57596,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238 /* EnumDeclaration */); + var node = createSynthesizedNode(241 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56923,7 +57615,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* ModuleDeclaration */); + var node = createSynthesizedNode(242 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -56942,7 +57634,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240 /* ModuleBlock */); + var node = createSynthesizedNode(243 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -56954,7 +57646,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241 /* CaseBlock */); + var node = createSynthesizedNode(244 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -56966,7 +57658,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -56978,7 +57670,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56996,7 +57688,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244 /* ImportDeclaration */); + var node = createSynthesizedNode(247 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -57014,7 +57706,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245 /* ImportClause */); + var node = createSynthesizedNode(248 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -57028,7 +57720,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246 /* NamespaceImport */); + var node = createSynthesizedNode(249 /* NamespaceImport */); node.name = name; return node; } @@ -57040,7 +57732,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247 /* NamedImports */); + var node = createSynthesizedNode(250 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -57052,7 +57744,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248 /* ImportSpecifier */); + var node = createSynthesizedNode(251 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -57066,7 +57758,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249 /* ExportAssignment */); + var node = createSynthesizedNode(252 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -57083,7 +57775,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ExportDeclaration */); + var node = createSynthesizedNode(253 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -57101,7 +57793,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251 /* NamedExports */); + var node = createSynthesizedNode(254 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -57113,7 +57805,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252 /* ExportSpecifier */); + var node = createSynthesizedNode(255 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -57128,7 +57820,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254 /* ExternalModuleReference */); + var node = createSynthesizedNode(257 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -57141,7 +57833,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255 /* JsxElement */); + var node = createSynthesizedNode(258 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -57157,7 +57849,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57173,7 +57865,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257 /* JsxOpeningElement */); + var node = createSynthesizedNode(260 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57189,7 +57881,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258 /* JsxClosingElement */); + var node = createSynthesizedNode(261 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -57201,7 +57893,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259 /* JsxFragment */); + var node = createSynthesizedNode(262 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -57217,7 +57909,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262 /* JsxAttribute */); + var node = createSynthesizedNode(265 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -57231,7 +57923,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263 /* JsxAttributes */); + var node = createSynthesizedNode(266 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -57243,7 +57935,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -57255,7 +57947,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265 /* JsxExpression */); + var node = createSynthesizedNode(268 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -57269,7 +57961,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266 /* CaseClause */); + var node = createSynthesizedNode(269 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -57283,7 +57975,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267 /* DefaultClause */); + var node = createSynthesizedNode(270 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -57295,7 +57987,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268 /* HeritageClause */); + var node = createSynthesizedNode(271 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -57308,7 +58000,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269 /* CatchClause */); + var node = createSynthesizedNode(272 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -57323,7 +58015,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270 /* PropertyAssignment */); + var node = createSynthesizedNode(273 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -57338,7 +58030,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -57352,7 +58044,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272 /* SpreadAssignment */); + var node = createSynthesizedNode(275 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -57365,7 +58057,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273 /* EnumMember */); + var node = createSynthesizedNode(276 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -57386,7 +58078,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274 /* SourceFile */); + var updated = createSynthesizedNode(277 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -57470,7 +58162,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301 /* NotEmittedStatement */); + var node = createSynthesizedNode(304 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -57482,7 +58174,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(308 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57494,7 +58186,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(307 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57509,7 +58201,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(302 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(305 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -57525,7 +58217,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 === 303 /* CommaListExpression */) { + if (node.kind === 306 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -57535,7 +58227,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303 /* CommaListExpression */); + var node = createSynthesizedNode(306 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -57548,14 +58240,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275 /* Bundle */); + var node = ts.createNode(278 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276 /* UnparsedSource */); + var node = ts.createNode(279 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -57563,7 +58255,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277 /* InputFiles */); + var node = ts.createNode(280 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -57706,7 +58398,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 === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -58217,7 +58909,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -58235,13 +58927,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -58268,7 +58960,7 @@ var ts; } else { switch (callee.kind) { - case 185 /* PropertyAccessExpression */: { + case 187 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58281,7 +58973,7 @@ var ts; } break; } - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58341,9 +59033,9 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -58668,7 +59360,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 === 191 /* ParenthesizedExpression */) { + if (skipped.kind === 193 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -58702,8 +59394,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(200 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -58712,7 +59404,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 203 /* YieldExpression */) { + && operand.kind === 205 /* YieldExpression */) { return false; } return true; @@ -58800,7 +59492,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -58815,7 +59507,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -58829,8 +59521,7 @@ 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 === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 303 /* CommaListExpression */ + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } @@ -58848,10 +59539,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 /* ClassExpression */ || - check.kind === 192 /* FunctionExpression */ || - check.kind === 303 /* CommaListExpression */ || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) + return check.kind === 207 /* ClassExpression */ || + check.kind === 194 /* FunctionExpression */ || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -58865,9 +59555,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.createParen(expression); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -58890,7 +59580,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -58928,7 +59618,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -58939,27 +59629,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { + if (kind === 194 /* FunctionExpression */ || kind === 195 /* 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 === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { + if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: return ts.createParenthesizedType(member); @@ -58970,8 +59660,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 172 /* InferType */: + case 177 /* TypeOperator */: + case 174 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -58997,25 +59687,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: node = node.operand; continue; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: node = node.left; continue; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: node = node.condition; continue; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: - node = node.expression; - continue; - case 302 /* PartiallyEmittedExpression */: + case 210 /* AsExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 211 /* NonNullExpression */: + case 305 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -59023,12 +59713,17 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || + node.kind === 306 /* CommaListExpression */; + } + ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; @@ -59039,13 +59734,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 209 /* NonNullExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 211 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -59070,7 +59765,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { node = node.expression; } return node; @@ -59078,11 +59773,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - 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 302 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -59100,7 +59795,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 191 /* ParenthesizedExpression */ + return node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -59165,10 +59860,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -59287,7 +59982,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -59299,11 +59994,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -59336,11 +60031,11 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 204 /* SpreadElement */: - case 272 /* SpreadAssignment */: + case 206 /* SpreadElement */: + case 275 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -59352,7 +60047,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -59364,7 +60059,7 @@ var ts; : propertyName; } break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -59376,7 +60071,7 @@ var ts; : propertyName; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -59394,13 +60089,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -59440,11 +60135,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -59568,7 +60263,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -59605,7 +60300,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { return node; } switch (kind) { @@ -59660,217 +60355,221 @@ var ts; case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168 /* TupleType */: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* UnionType */: + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 169 /* OptionalType */: + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* RestType */: + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 171 /* ConditionalType */: + case 173 /* 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 172 /* InferType */: + case 174 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179 /* ImportType */: + case 181 /* 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 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177 /* MappedType */: + case 179 /* 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 178 /* LiteralType */: + case 180 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182 /* BindingElement */: + case 184 /* 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 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* FunctionExpression */: + case 194 /* 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 193 /* ArrowFunction */: + case 195 /* 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 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201 /* ConditionalExpression */: + case 203 /* 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 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 213 /* Block */: + case 216 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 216 /* ExpressionStatement */: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* IfStatement */: + case 219 /* ExpressionStatement */: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* 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 218 /* DoStatement */: + case 221 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: + case 224 /* 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 222 /* ForOfStatement */: + case 225 /* 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 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234 /* FunctionDeclaration */: + case 237 /* 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 235 /* ClassDeclaration */: + case 238 /* 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 236 /* InterfaceDeclaration */: + case 239 /* 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 237 /* TypeAliasDeclaration */: + case 240 /* 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 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250 /* ExportDeclaration */: + case 253 /* 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 251 /* NamedExports */: + case 254 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -59916,17 +60615,17 @@ var ts; return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 212 /* SemicolonClassElement */: - case 215 /* EmptyStatement */: - case 206 /* OmittedExpression */: - case 231 /* DebuggerStatement */: - case 301 /* NotEmittedStatement */: + case 215 /* SemicolonClassElement */: + case 218 /* EmptyStatement */: + case 208 /* OmittedExpression */: + case 234 /* DebuggerStatement */: + case 304 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -59993,49 +60692,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* NewExpression */: + case 190 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -60043,123 +60742,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ArrowFunction */: + case 195 /* 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 191 /* ParenthesizedExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208 /* AsExpression */: + case 210 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 213 /* Block */: + case 216 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219 /* WhileStatement */: - case 226 /* WithStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60168,7 +60867,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60176,139 +60875,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -60381,7 +61080,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 !== 207 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -60625,7 +61324,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -60772,7 +61470,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -60818,7 +61516,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -60826,13 +61524,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + case 246 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -60862,13 +61560,13 @@ var ts; } } break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -60876,7 +61574,7 @@ var ts; } } break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -60896,7 +61594,7 @@ var ts; } } break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -61512,13 +62210,14 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -61542,14 +62241,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* 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 === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -61577,16 +62276,18 @@ var ts; */ function saveStateAndInvoke(node, f) { // Save state - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } /** @@ -61596,15 +62297,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 240 /* ModuleBlock */: - case 213 /* Block */: - currentScope = node; + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 243 /* ModuleBlock */: + case 216 /* Block */: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -61616,7 +62318,11 @@ 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 === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } + if (ts.isClassDeclaration(node)) { + // XXX: should probably also cover interfaces and type aliases that can have type variables? + currentNameScope = node; } break; } @@ -61660,10 +62366,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -61684,13 +62390,13 @@ var ts; return node; } switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -61710,11 +62416,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 250 /* ExportDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 245 /* ImportClause */ || - (node.kind === 243 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 254 /* ExternalModuleReference */)) { + if (node.kind === 253 /* ExportDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 248 /* ImportClause */ || + (node.kind === 246 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 257 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -61756,7 +62462,7 @@ var ts; case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -61797,6 +62503,8 @@ var ts; // TypeScript accessibility and readonly modifiers are elided. case 167 /* ArrayType */: case 168 /* TupleType */: + case 169 /* OptionalType */: + case 170 /* RestType */: case 166 /* TypeLiteral */: case 161 /* TypePredicate */: case 148 /* TypeParameter */: @@ -61812,36 +62520,36 @@ var ts; 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 */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 175 /* ParenthesizedType */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: // TypeScript type nodes are elided. case 160 /* IndexSignature */: // TypeScript index signatures are elided. case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; 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 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; case 155 /* Constructor */: return visitConstructor(node); - case 236 /* InterfaceDeclaration */: + case 239 /* 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61852,7 +62560,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61863,13 +62571,13 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); case 154 /* MethodDeclaration */: @@ -61882,13 +62590,13 @@ var ts; case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case 149 /* Parameter */: @@ -61901,35 +62609,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -61965,7 +62673,7 @@ var ts; var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) @@ -62008,7 +62716,7 @@ var ts; var statements = [classStatement]; // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -62369,7 +63077,7 @@ var ts; // // super(...arguments); // - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } // Add the property initializers. Transforms this: @@ -62411,7 +63119,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -62448,7 +63156,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -62495,7 +63203,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -62798,7 +63506,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } /** @@ -62925,8 +63633,8 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -62948,8 +63656,8 @@ var ts; return serializeTypeNode(node.type); case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: @@ -63037,7 +63745,7 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return serializeTypeNode(node.type); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -63052,7 +63760,7 @@ var ts; return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -63072,18 +63780,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: return serializeUnionOrIntersectionType(node); case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: case 142 /* UnknownKeyword */: - case 174 /* ThisType */: - case 179 /* ImportType */: + case 176 /* ThisType */: + case 181 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63096,7 +63804,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -63135,7 +63843,7 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); @@ -63182,7 +63890,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. + name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -63516,7 +64224,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -63597,7 +64305,7 @@ var ts; * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -63621,7 +64329,7 @@ var ts; // enum body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63646,7 +64354,7 @@ var ts; // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63694,7 +64402,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } /** * Transforms the value of an enum member. @@ -63772,12 +64480,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 === 274 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 277 /* 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 === 238 /* EnumDeclaration */) { + if (node.kind === 241 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -63839,7 +64547,7 @@ var ts; // module body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63863,7 +64571,7 @@ var ts; // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63896,7 +64604,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240 /* ModuleBlock */) { + if (body.kind === 243 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -63942,13 +64650,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 !== 240 /* ModuleBlock */) { + if (body.kind !== 243 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -63989,7 +64697,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 246 /* NamespaceImport */) { + if (node.kind === 249 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -64144,17 +64852,17 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -64221,16 +64929,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(271 /* ShorthandPropertyAssignment */); + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(239 /* ModuleDeclaration */); + context.enableEmitNotification(242 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; } /** * Hook for node emit. @@ -64291,9 +64999,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -64331,9 +65039,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 !== 274 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); + if (container && container.kind !== 277 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -64468,15 +65176,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -64485,27 +65193,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - 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 */: + case 216 /* Block */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 229 /* WithStatement */: + case 231 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -64540,7 +65248,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -64706,7 +65414,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 === 193 /* ArrowFunction */; + var isArrowFunction = node.kind === 195 /* 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 @@ -64779,11 +65487,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -64827,11 +65535,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -64863,7 +65571,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -64962,25 +65670,25 @@ var ts; return node; } switch (node.kind) { - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitVoidExpression(node); case 155 /* Constructor */: return visitConstructorDeclaration(node); @@ -64990,19 +65698,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); case 149 /* Parameter */: return visitParameter(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -65036,7 +65744,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -65048,7 +65756,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 === 272 /* SpreadAssignment */) { + if (e.kind === 275 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -65057,7 +65765,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -65075,7 +65783,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 !== 184 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -65214,13 +65922,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -65388,11 +66096,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -65436,11 +66144,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -65472,7 +66180,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -65585,13 +66293,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -65601,13 +66309,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -65682,7 +66390,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265 /* JsxExpression */) { + else if (node.kind === 268 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -65776,7 +66484,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255 /* JsxElement */) { + if (node.kind === 258 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -66082,7 +66790,7 @@ var ts; return node; } switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66315,13 +67023,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 225 /* ReturnStatement */ + && node.kind === 228 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -66349,63 +67057,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return visitClassExpression(node); case 149 /* Parameter */: return visitParameter(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -66416,28 +67124,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitMetaProperty(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -66524,14 +67232,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 === 224 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -66542,7 +67250,7 @@ var ts; } } else { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -66659,7 +67367,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -66723,7 +67431,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), /*location*/ extendsClauseElement)); } } @@ -66842,11 +67550,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 225 /* ReturnStatement */) { + if (statement.kind === 228 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 217 /* IfStatement */) { + else if (statement.kind === 220 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -66854,7 +67562,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 213 /* Block */) { + else if (statement.kind === 216 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -66912,7 +67620,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -66922,8 +67630,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 /* BinaryExpression */ - || superCallExpression.left.kind !== 187 /* CallExpression */) { + if (superCallExpression.kind !== 202 /* BinaryExpression */ + || superCallExpression.left.kind !== 189 /* 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. @@ -67038,7 +67746,7 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -67052,7 +67760,7 @@ var ts; function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -67104,7 +67812,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ - ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) @@ -67120,7 +67828,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -67140,7 +67848,7 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return statements; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -67154,8 +67862,8 @@ var ts; // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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()); @@ -67186,7 +67894,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: @@ -67230,7 +67938,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -67248,7 +67956,7 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); + var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. @@ -67391,7 +68099,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 === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -67436,7 +68144,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193 /* ArrowFunction */); + ts.Debug.assert(node.kind === 195 /* 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 @@ -67504,10 +68212,10 @@ 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 191 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + case 193 /* ParenthesizedExpression */: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 202 /* BinaryExpression */: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); } @@ -67525,9 +68233,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 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -67569,7 +68277,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -67728,14 +68436,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -67793,11 +68501,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -67886,13 +68594,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -67991,11 +68699,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -68159,7 +68867,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -68176,7 +68884,7 @@ var ts; ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { @@ -68285,10 +68993,10 @@ var ts; case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -68540,7 +69248,7 @@ var ts; statements.push(funcStatements[classBodyStart]); classBodyStart++; // Add the class alias following the declaration. - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } // Find the trailing 'return' statement (4) while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { @@ -68677,7 +69385,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -68944,9 +69652,9 @@ var ts; context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(193 /* ArrowFunction */); - context.enableEmitNotification(192 /* FunctionExpression */); - context.enableEmitNotification(234 /* FunctionDeclaration */); + context.enableEmitNotification(195 /* ArrowFunction */); + context.enableEmitNotification(194 /* FunctionExpression */); + context.enableEmitNotification(237 /* FunctionDeclaration */); } } /** @@ -68987,10 +69695,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 235 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -69072,11 +69780,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -69084,7 +69792,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -69137,15 +69845,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257 /* JsxOpeningElement */); - context.enableEmitNotification(258 /* JsxClosingElement */); - context.enableEmitNotification(256 /* JsxSelfClosingElement */); + context.enableEmitNotification(260 /* JsxOpeningElement */); + context.enableEmitNotification(261 /* JsxClosingElement */); + context.enableEmitNotification(259 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(270 /* PropertyAssignment */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(273 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -69164,9 +69872,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -69498,13 +70206,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -69517,24 +70225,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return visitBreakStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return visitContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -69555,21 +70263,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitConditionalExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69582,9 +70290,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -69760,7 +70468,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } /** @@ -69812,7 +70520,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -69824,7 +70532,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -69948,7 +70656,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* Statement */, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -70101,7 +70809,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -70200,35 +70908,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: return transformAndEmitBlock(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return transformAndEmitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return transformAndEmitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return transformAndEmitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return transformAndEmitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -70265,7 +70973,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -70416,7 +71124,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -70426,7 +71134,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -70487,7 +71195,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); @@ -70510,7 +71218,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -70658,7 +71366,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -70671,7 +71379,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -71534,7 +72242,7 @@ var ts; // indicate entry into a protected region by pushing the label numbers // for each block in the protected region. var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, [ ts.createArrayLiteral([ createLabel(startLabel), @@ -71548,7 +72256,7 @@ var ts; if (markLabelEnd) { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -71706,7 +72414,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -71900,11 +72608,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported 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.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(277 /* 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. @@ -71997,7 +72705,7 @@ var ts; // // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, + ts.createExpressionStatement(ts.createCall(define, /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ // Add the dependency array argument: // @@ -72048,9 +72756,9 @@ var ts; ts.createIdentifier("exports") ])) ]), - ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -72074,7 +72782,7 @@ var ts; // } // })(function ...) var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, + ts.createExpressionStatement(ts.createCall(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // @@ -72153,7 +72861,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. @@ -72208,7 +72916,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); @@ -72226,23 +72934,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -72269,17 +72977,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -72373,7 +73081,7 @@ var ts; ts.createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; @@ -72468,7 +73176,7 @@ var ts; if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -72536,7 +73244,7 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( @@ -72549,7 +73257,7 @@ var ts; } else { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -72588,13 +73296,13 @@ var ts; for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { // export * from "mod"; - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } /** @@ -72700,7 +73408,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -72761,7 +73469,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -72816,10 +73524,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -72949,10 +73657,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), @@ -72973,7 +73681,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, location, allowComments) { - var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -73018,7 +73726,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -73082,10 +73790,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -73106,7 +73814,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -73181,7 +73889,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -73257,11 +73965,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - 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. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(277 /* 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. @@ -73323,7 +74031,7 @@ var ts; var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) @@ -73482,7 +74190,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -73507,7 +74215,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250 /* ExportDeclaration */) { + if (externalImport.kind !== 253 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -73561,9 +74269,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) ])), - ts.createStatement(ts.createCall(exportFunction, + ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) ], /*multiline*/ true)); } @@ -73585,19 +74293,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -73613,7 +74321,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { @@ -73622,7 +74330,7 @@ var ts; // emit as: // // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, /*typeArguments*/ undefined, [parameterName]))); } break; @@ -73647,15 +74355,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -73756,7 +74464,7 @@ var ts; var name = ts.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -73793,7 +74501,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -73831,7 +74539,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 === 274 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 277 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -73895,7 +74603,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 === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -73957,10 +74665,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -74112,7 +74820,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -74140,43 +74848,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitDefaultClause(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitTryStatement(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -74359,7 +75067,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 200 /* BinaryExpression */) { + && node.kind === 202 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -74424,7 +75132,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274 /* SourceFile */; + return container !== undefined && container.kind === 277 /* SourceFile */; } else { return false; @@ -74457,7 +75165,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -74505,7 +75213,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -74541,10 +75249,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -74637,14 +75345,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* 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 === 199 /* PostfixUnaryExpression */) { + if (node.kind === 201 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -74666,7 +75374,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -74705,7 +75413,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274 /* SourceFile */); + context.enableEmitNotification(277 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -74734,10 +75442,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -74844,7 +75552,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74873,7 +75581,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74920,7 +75628,7 @@ var ts; 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 === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* 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 : @@ -74939,7 +75647,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 === 235 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 238 /* 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 : @@ -75030,7 +75738,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -75044,7 +75752,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234 /* FunctionDeclaration */: + case 237 /* 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 : @@ -75100,7 +75808,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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 : @@ -75113,7 +75821,7 @@ 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 163 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -75128,10 +75836,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159 /* ConstructSignature */: @@ -75145,17 +75853,17 @@ var ts; 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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -75170,7 +75878,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 235 /* ClassDeclaration */) { + if (node.parent.parent.kind === 238 /* 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 : @@ -75267,7 +75975,13 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + // If it is visible via `// `, then we should just use that + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -75322,10 +76036,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -75353,7 +76067,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -75451,7 +76165,7 @@ var ts; return name; } else { - if (name.kind === 181 /* ArrayBindingPattern */) { + if (name.kind === 183 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -75459,7 +76173,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206 /* OmittedExpression */) { + if (elem.kind === 208 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -75517,7 +76231,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 /* Parameter */ @@ -75539,20 +76253,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return false; } return false; @@ -75606,7 +76320,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -75618,7 +76332,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -75645,7 +76359,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 === 246 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 249 /* 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; @@ -75750,14 +76464,14 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* 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 207 /* ExpressionWithTypeArguments */: { + case 209 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -75811,7 +76525,7 @@ var ts; return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -75825,7 +76539,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171 /* ConditionalType */: { + case 173 /* 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); @@ -75843,7 +76557,7 @@ var ts; case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179 /* ImportType */: { + case 181 /* 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)); @@ -75882,7 +76596,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250 /* ExportDeclaration */: { + case 253 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -75891,7 +76605,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -75921,10 +76635,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -75945,24 +76659,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 240 /* 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 236 /* InterfaceDeclaration */: { + case 239 /* 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 234 /* FunctionDeclaration */: { + case 237 /* 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 239 /* ModuleDeclaration */: { + case 242 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240 /* ModuleBlock */) { + if (inner && inner.kind === 243 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -75983,7 +76697,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 235 /* ClassDeclaration */: { + case 238 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -76023,7 +76737,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(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"); // TODO: GH#18217 @@ -76053,10 +76767,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238 /* EnumDeclaration */: { + case 241 /* 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; @@ -76075,7 +76789,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239 /* ModuleDeclaration */) { + if (input.kind === 242 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -76096,7 +76810,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206 /* OmittedExpression */) { + if (e.kind === 208 /* OmittedExpression */) { return; } if (e.name) { @@ -76150,7 +76864,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 === 274 /* SourceFile */; + var parentIsFile = node.parent.kind === 277 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -76171,7 +76885,7 @@ var ts; var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3 /* MultiLineCommentTrivia */) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -76185,7 +76899,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -76198,7 +76912,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* InterfaceDeclaration */) { return true; } return false; @@ -76227,7 +76941,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: @@ -76237,17 +76951,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - 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 */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 217 /* VariableStatement */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return true; } return false; @@ -76264,14 +76978,14 @@ var ts; case 153 /* MethodSignature */: case 158 /* CallSignature */: case 160 /* IndexSignature */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 148 /* TypeParameter */: - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: case 162 /* TypeReference */: - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 179 /* ImportType */: + case 181 /* ImportType */: return true; } return false; @@ -76347,7 +77061,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(306 /* Count */); + var enabledSyntaxKindFeatures = new Array(309 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -76682,7 +77396,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap @@ -76692,7 +77405,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 277 /* 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)); @@ -76783,7 +77496,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** * Emits a mapping. @@ -76843,6 +77555,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -76853,50 +77566,55 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { // empty } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); // First, decode the old component sourcemap - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -76913,7 +77631,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -76968,13 +77686,15 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - // 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 - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + // 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 + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -77090,7 +77810,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 304 /* 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 */; @@ -77111,7 +77831,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 === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -77453,7 +78173,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275 /* Bundle */) { + if (sourceFile.kind === 278 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; @@ -77588,6 +78308,11 @@ var ts; // Setup and perform the transformation to retrieve declarations from the input files var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + // Checker wont collect the linked aliases since thats only done when declaration is enabled. + // Do that here when emitting only dts files + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -77615,9 +78340,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71 /* Identifier */) { + resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -77717,9 +78455,9 @@ var ts; break; } switch (node.kind) { - case 274 /* SourceFile */: return printFile(node); - case 275 /* Bundle */: return printBundle(node); - case 276 /* UnparsedSource */: return printUnparsedSource(node); + case 277 /* SourceFile */: return printFile(node); + case 278 /* Bundle */: return printBundle(node); + case 279 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -77864,7 +78602,7 @@ var ts; } return pipelineEmitWithoutComments; case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { return pipelineEmitWithSourceMap; } // falls through @@ -77890,7 +78628,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); + ts.Debug.assert(hint !== 0 /* SourceFile */); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -77909,7 +78647,7 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 276 /* UnparsedSource */: + case 279 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: @@ -77954,7 +78692,7 @@ var ts; return emitTypeReference(node); case 163 /* FunctionType */: return emitFunctionType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 164 /* ConstructorType */: return emitConstructorType(node); @@ -77966,178 +78704,181 @@ var ts; return emitArrayType(node); case 168 /* TupleType */: return emitTupleType(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return emitOptionalType(node); + case 171 /* UnionType */: return emitUnionType(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return emitIntersectionType(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return emitConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return emitInferType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return emitParenthesizedType(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return emitThisType(); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return emitTypeOperator(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return emitMappedType(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return emitLiteralType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return emitImportTypeNode(node); - case 279 /* JSDocAllType */: + case 282 /* JSDocAllType */: write("*"); return; - case 280 /* JSDocUnknownType */: + case 283 /* JSDocUnknownType */: write("?"); return; - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 285 /* JSDocVariadicType */: - return emitJSDocVariadicType(node); + case 170 /* RestType */: + case 288 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return emitBindingElement(node); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return emitTemplateSpan(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 213 /* Block */: + case 216 /* Block */: return emitBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return emitVariableStatement(node); - case 215 /* EmptyStatement */: + case 218 /* EmptyStatement */: return emitEmptyStatement(); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return emitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return emitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return emitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return emitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return emitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return emitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return emitForOfStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return emitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return emitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return emitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return emitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return emitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return emitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return emitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return emitTryStatement(node); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return emitClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return emitModuleBlock(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return emitCaseBlock(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return emitImportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return emitImportClause(node); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return emitNamespaceImport(node); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return emitNamedImports(node); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return emitImportSpecifier(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return emitExportDeclaration(node); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return emitNamedExports(node); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return emitExportSpecifier(node); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return; // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 258 /* JsxClosingElement */: - case 261 /* JsxClosingFragment */: + case 261 /* JsxClosingElement */: + case 264 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return emitJsxAttribute(node); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return emitJsxAttributes(node); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return emitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return emitDefaultClause(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return emitHeritageClause(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -78172,71 +78913,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return emitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return emitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return emitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return emitArrowFunction(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return emitDeleteExpression(node); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return emitVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return emitAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return emitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return emitConditionalExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return emitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return emitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return emitSpreadExpression(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return emitClassExpression(node); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: return emitAsExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return emitNonNullExpression(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return emitJsxElement(node); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return emitCommaList(node); } } @@ -78253,7 +78994,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 /* Bundle */ ? node : undefined; + var bundle = node.kind === 278 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -78379,7 +79120,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -78548,7 +79289,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -78557,6 +79298,10 @@ var ts; emitList(node, node.elementTypes, 272 /* TupleTypeElements */); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260 /* UnionTypeConstituents */); } @@ -78838,7 +79583,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 === 198 /* PrefixUnaryExpression */ + return operand.kind === 200 /* 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 */))); } @@ -78958,7 +79703,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217 /* IfStatement */) { + if (node.elseStatement.kind === 220 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -79029,7 +79774,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { emit(node); } else { @@ -79131,7 +79876,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272 /* VariableDeclarationList */); } @@ -79324,7 +80069,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239 /* ModuleDeclaration */) { + while (body.kind === 242 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -80249,7 +80994,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -80314,81 +81059,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: ts.forEach(node.statements, generateNames); break; - case 228 /* LabeledStatement */: - case 226 /* WithStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 231 /* LabeledStatement */: + case 229 /* WithStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: generateNames(node.statement); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: generateNames(node.declarationList); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: generateNames(node.importClause); break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -80397,8 +81142,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 152 /* PropertyDeclaration */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -80584,17 +81329,17 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 252 /* ExportAssignment */: return generateNameForExportDefault(); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return generateNameForClassExpression(); case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -81255,17 +82000,20 @@ var ts; } return context; } - function formatLocation(file, start, host) { + /* @internal */ + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -81284,11 +82032,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -82015,7 +82763,16 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + // Use local caches + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + // Before falling back to the host + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -82275,10 +83032,10 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: - case 232 /* VariableDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: + case 235 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -82286,41 +83043,41 @@ var ts; } } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268 /* HeritageClause */: + case 271 /* 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 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -82333,25 +83090,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 235 /* ClassDeclaration */: + case 238 /* 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 */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* 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 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); } break; case 152 /* PropertyDeclaration */: @@ -82373,11 +83130,11 @@ var ts; return; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -83043,14 +83800,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -84704,11 +85461,12 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - // Note: fromSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + // Note: importingSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -84721,7 +85479,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); 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); @@ -84739,13 +85497,13 @@ var ts; 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); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } 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); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -84815,11 +85573,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0 /* EqualTo */) { resolvedParts.pop(); originalParts.pop(); } @@ -84853,17 +85612,16 @@ var ts; return [target]; } /** - * Looks for a existing imports that use symlinks to this module. + * Looks for existing imports that use symlinks to this module. * Only if no symlink is available, the real path will be used. */ - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -84939,7 +85697,7 @@ var ts; var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // 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))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); @@ -85347,7 +86105,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; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; 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); @@ -85879,16 +86637,20 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */) ? ".jsx" /* Jsx */ : ".js" /* Js */); + var newExtension = ts.fileExtensionIs(inputFileName, ".json" /* Json */) ? ".json" /* Json */ : + ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -86060,9 +86822,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -86112,7 +86871,7 @@ var ts; // Everything is broken - we don't even know what to watch. Give up. return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { // Watch this file @@ -86139,7 +86898,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -86344,14 +87103,18 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -86359,7 +87122,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -86655,12 +87422,12 @@ var ts; } // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -86729,7 +87496,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; @@ -86752,18 +87519,24 @@ var ts; })(ts || (ts = {})); //# sourceMappingURL=compiler.js.map "use strict"; -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); }; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -86799,7 +87572,7 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ - ts.defaultPreferences = {}; + ts.emptyOptions = {}; var TextChange = /** @class */ (function () { function TextChange() { } @@ -87035,35 +87808,35 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 149 /* Parameter */: - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* 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 */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 272 /* CatchClause */: + case 265 /* JsxAttribute */: return 1 /* Value */; case 148 /* TypeParameter */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: case 166 /* TypeLiteral */: return 2 /* Type */; - case 298 /* JSDocTypedefTag */: + case 301 /* 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 273 /* EnumMember */: - case 235 /* ClassDeclaration */: + case 276 /* EnumMember */: + case 238 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -87073,26 +87846,26 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* EnumDeclaration */: - case 247 /* NamedImports */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 241 /* EnumDeclaration */: + case 250 /* NamedImports */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 249 /* ExportAssignment */) { + else if (node.parent.kind === 252 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -87125,7 +87898,7 @@ var ts; // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // 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 */; + return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { while (node.parent.kind === 146 /* QualifiedName */) { @@ -87151,16 +87924,16 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 185 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { + if (root.parent.kind === 187 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -87171,25 +87944,25 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return true; } switch (node.parent.kind) { case 162 /* TypeReference */: return true; - case 179 /* ImportType */: + case 181 /* ImportType */: return !node.parent.isTypeOf; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 189 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 190 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -87202,7 +87975,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -87227,11 +88000,11 @@ var ts; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -87243,20 +88016,20 @@ var ts; switch (node.parent.kind) { case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 273 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 276 /* EnumMember */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return node.parent.argumentExpression === node; case 147 /* ComputedPropertyName */: return true; - case 178 /* LiteralType */: - return node.parent.parent.kind === 176 /* IndexedAccessType */; + case 180 /* LiteralType */: + return node.parent.parent.kind === 178 /* IndexedAccessType */; default: return false; } @@ -87280,17 +88053,17 @@ var ts; return undefined; } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return node; } } @@ -87298,26 +88071,26 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return "class" /* classElement */; - case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 237 /* TypeAliasDeclaration */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 240 /* TypeAliasDeclaration */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 238 /* EnumDeclaration */: return "enum" /* enumElement */; - case 232 /* VariableDeclaration */: + case 241 /* EnumDeclaration */: return "enum" /* enumElement */; + case 235 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return "function" /* functionElement */; case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; @@ -87332,15 +88105,14 @@ var ts; 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 276 /* 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 */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: + case 249 /* NamespaceImport */: return "alias" /* alias */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -87364,11 +88136,13 @@ var ts; return "" /* unknown */; } } + case 71 /* Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; } function getKindOfVariableDeclaration(v) { - return ts.isConst(v) + return ts.isVarConst(v) ? "const" /* constElement */ : ts.isLet(v) ? "let" /* letElement */ @@ -87401,6 +88175,10 @@ var ts; return startEndContainsRange(r1.pos, r1.end, r2); } ts.rangeContainsRange = rangeContainsRange; + function rangeContainsRangeExclusive(r1, r2) { + return rangeContainsPositionExclusive(r1, r2.pos) && rangeContainsPositionExclusive(r1, r2.end); + } + ts.rangeContainsRangeExclusive = rangeContainsRangeExclusive; function rangeContainsPosition(r, pos) { return r.pos <= pos && pos <= r.end; } @@ -87421,6 +88199,10 @@ var ts; return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); } ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function nodeOverlapsWithStartEnd(node, sourceFile, start, end) { + return startEndOverlapsWithStartEnd(node.getStart(sourceFile), node.end, start, end); + } + ts.nodeOverlapsWithStartEnd = nodeOverlapsWithStartEnd; function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { var start = Math.max(start1, start2); var end = Math.min(end1, end2); @@ -87440,28 +88222,28 @@ var ts; return false; } switch (n.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: - case 180 /* ObjectBindingPattern */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: case 166 /* TypeLiteral */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 241 /* CaseBlock */: - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 244 /* CaseBlock */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 188 /* NewExpression */: + case 190 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 187 /* CallExpression */: - case 191 /* ParenthesizedExpression */: - case 173 /* ParenthesizedType */: + case 189 /* CallExpression */: + case 193 /* ParenthesizedExpression */: + case 175 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -87469,13 +88251,13 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 159 /* ConstructSignature */: case 158 /* CallSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -87485,19 +88267,19 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 183 /* ArrayLiteralExpression */: - case 181 /* ArrayBindingPattern */: - case 186 /* ElementAccessExpression */: + case 185 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 188 /* ElementAccessExpression */: case 147 /* ComputedPropertyName */: case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); @@ -87506,44 +88288,44 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 218 /* DoStatement */: + case 221 /* 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 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 195 /* TypeOfExpression */: - case 194 /* DeleteExpression */: - case 196 /* VoidExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: + case 197 /* TypeOfExpression */: + case 196 /* DeleteExpression */: + case 198 /* VoidExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -87607,38 +88389,30 @@ var ts; * position >= start and (position < end or (position === end && token is literal or keyword or identifier)) */ function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, /*includeJsDocComment*/ true, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); + return getTouchingToken(sourceFile, position, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); } ts.getTouchingPropertyName = getTouchingPropertyName; /** * Returns the token if position is in [start, end). * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true */ - function getTouchingToken(sourceFile, position, includeJsDocComment, includePrecedingTokenAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false, includeJsDocComment); + function getTouchingToken(sourceFile, position, includePrecedingTokenAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false); } 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); + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, /*includeEndPosition*/ false); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition, includeJsDocComment) { + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition) { var current = sourceFile; outer: while (true) { - if (ts.isToken(current)) { - // exit early - return current; - } // find the child that contains 'position' for (var _i = 0, _a = current.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; - if (!includeJsDocComment && ts.isJSDocNode(child)) { - continue; - } - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { // If this child begins after position, then all subsequent children will as well. break; @@ -87669,7 +88443,7 @@ var ts; function findTokenOnLeftOfPosition(file, position) { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. - var tokenAtPosition = getTokenAtPosition(file, position, /*includeJsDocComment*/ false); + var tokenAtPosition = getTokenAtPosition(file, position); if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } @@ -87683,19 +88457,14 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - var children = n.getChildren(); - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; + return ts.firstDefined(n.getChildren(), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || // previous token ends exactly at the beginning of child (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child, sourceFile)) { - return find(child); - } - } - return undefined; + return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find(child) : undefined; + }); } } ts.findNextToken = findNextToken; @@ -87703,7 +88472,7 @@ var ts; * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { + function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) { var result = find(startNode || sourceFile); ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; @@ -87720,7 +88489,7 @@ var ts; // we need to find the last token in a previous child. // 2) `position` is within the same span: we recurse on `child`. if (position < child.end) { - var start = child.getStart(sourceFile, includeJsDoc); + var start = child.getStart(sourceFile, /*includeJsDoc*/ !excludeJsdoc); var lookInPreviousChild = (start >= position) || // cursor in the leading trivia !nodeHasTokens(child, sourceFile) || isWhiteSpaceOnlyJsxText(child); @@ -87735,7 +88504,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 277 /* 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. @@ -87795,7 +88564,7 @@ var ts; * returns true if the position is in between the open and close elements of an JSX expression. */ function isInsideJsxElementOrAttribute(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); if (!token) { return false; } @@ -87807,17 +88576,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { return true; } return false; @@ -87827,7 +88596,7 @@ var ts; return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; } function isInTemplateString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; @@ -87869,7 +88638,7 @@ var ts; if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { - return { called: token, nTypeArguments: nTypeArguments }; + return ts.isDeclarationName(token) ? undefined : { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -87939,19 +88708,13 @@ var ts; * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - function isInComment(sourceFile, position, tokenAtPosition, predicate) { - return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); + function isInComment(sourceFile, position, tokenAtPosition) { + return ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*precedingToken*/ undefined, tokenAtPosition); } ts.isInComment = isInComment; function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*"; - } + var token = getTokenAtPosition(sourceFile, position); + return !!ts.findAncestor(token, ts.isJSDoc); } ts.hasDocComment = hasDocComment; function nodeHasTokens(n, sourceFile) { @@ -87960,7 +88723,7 @@ var ts; return n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node) { - var flags = ts.getCombinedModifierFlags(node); + var flags = ts.isDeclaration(node) ? ts.getCombinedModifierFlags(node) : 0 /* None */; var result = []; if (flags & 8 /* Private */) result.push("private" /* privateMemberModifier */); @@ -87980,10 +88743,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -88028,18 +88791,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 183 /* ArrayLiteralExpression */ || - node.kind === 184 /* ObjectLiteralExpression */) { + if (node.kind === 185 /* ArrayLiteralExpression */ || + node.kind === 186 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 200 /* BinaryExpression */ && + if (node.parent.kind === 202 /* 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 === 222 /* ForOfStatement */ && + if (node.parent.kind === 225 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -88047,7 +88810,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -88055,19 +88818,17 @@ var ts; } ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; function isInReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ true); } ts.isInReferenceComment = isInReferenceComment; function isInNonReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ false); } ts.isInNonReferenceComment = isInNonReferenceComment; + function isInReferenceCommentWorker(sourceFile, position, shouldBeReference) { + var range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined); + return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); + } function createTextSpanFromNode(node, sourceFile) { return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); } @@ -88181,13 +88942,17 @@ var ts; QuotePreference[QuotePreference["Single"] = 0] = "Single"; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); + function quotePreferenceFromString(str, sourceFile) { + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + } + ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference) { return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; } else { - var firstModuleSpecifier = ts.firstOrUndefined(sourceFile.imports); - return !!firstModuleSpecifier && !ts.isStringDoubleQuoted(firstModuleSpecifier, sourceFile) ? 0 /* Single */ : 1 /* Double */; + var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, ts.isStringLiteral); + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; } } ts.getQuotePreference = getQuotePreference; @@ -88267,6 +89032,37 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + var NodeMap = /** @class */ (function () { + function NodeMap() { + this.map = ts.createMap(); + } + NodeMap.prototype.get = function (node) { + var res = this.map.get(String(ts.getNodeId(node))); + return res && res.value; + }; + NodeMap.prototype.getOrUpdate = function (node, setValue) { + var res = this.get(node); + if (res) + return res; + var value = setValue(); + this.set(node, value); + return value; + }; + NodeMap.prototype.set = function (node, value) { + this.map.set(String(ts.getNodeId(node)), { node: node, value: value }); + }; + NodeMap.prototype.has = function (node) { + return this.map.has(String(ts.getNodeId(node))); + }; + NodeMap.prototype.forEach = function (cb) { + this.map.forEach(function (_a) { + var node = _a.node, value = _a.value; + return cb(value, node); + }); + }; + return NodeMap; + }()); + ts.NodeMap = NodeMap; function getParentNodeInSpan(node, file, span) { if (!node) return undefined; @@ -88282,6 +89078,10 @@ var ts; return ts.textSpanContainsPosition(span, node.getStart(file)) && node.getEnd() <= ts.textSpanEnd(span); } + function findModifier(node, kind) { + return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); + } + ts.findModifier = findModifier; /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); @@ -88494,7 +89294,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && + (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -89112,10 +89912,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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -89327,18 +90127,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 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -89425,22 +90225,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -89469,17 +90269,17 @@ var ts; var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 232 /* VariableDeclaration */ || + if (parent.kind === 235 /* VariableDeclaration */ || parent.kind === 152 /* PropertyDeclaration */ || parent.kind === 149 /* Parameter */ || - parent.kind === 262 /* JsxAttribute */) { + parent.kind === 265 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 200 /* BinaryExpression */ || - parent.kind === 198 /* PrefixUnaryExpression */ || - parent.kind === 199 /* PostfixUnaryExpression */ || - parent.kind === 201 /* ConditionalExpression */) { + if (parent.kind === 202 /* BinaryExpression */ || + parent.kind === 200 /* PrefixUnaryExpression */ || + parent.kind === 201 /* PostfixUnaryExpression */ || + parent.kind === 203 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -89490,7 +90290,7 @@ var ts; } else if (tokenKind === 9 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -89506,7 +90306,7 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -89516,17 +90316,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -89578,12 +90378,12 @@ var ts; }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker)); + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; - function getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; + var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); @@ -89595,7 +90395,6 @@ var ts; } } else { - // Check for node modules return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } } @@ -89761,14 +90560,16 @@ var ts; function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") && ts.startsWith(path, fragment) ? [{ name: path, kind: "directory" /* directory */ }] : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); - if (!ts.startsWith(fragment, pathPrefix)) { - return [{ name: pathPrefix, kind: "directory" /* directory */ }]; + var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); + return remainingFragment === undefined ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { + return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); + }); + function justPathMappingName(name) { + return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; } - var remainingFragment = fragment.slice(pathPrefix.length); - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { if (!host.readDirectory) { @@ -89825,7 +90626,7 @@ var ts; return nonRelativeModuleNames; } function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { - var token = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, position); var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); var range = commentRanges && ts.find(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end; }); if (!range) { @@ -90298,11 +91099,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.parent.parent.kind) { case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent)), isNewIdentifier: false }; - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -90310,12 +91111,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 179 /* ImportType */: + case 181 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 270 /* PropertyAssignment */: + case 273 /* 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 { @@ -90332,7 +91133,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -90345,8 +91146,8 @@ var ts; } return undefined; } - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -90355,9 +91156,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 254 /* ExternalModuleReference */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 257 /* 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*/"); @@ -90434,7 +91235,7 @@ var ts; || ts.codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) : symbol.name; } - function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, getCanonicalFileName, preferences, cancellationToken) { + function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); var name = entryId.name; @@ -90463,7 +91264,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; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -90506,14 +91307,14 @@ var ts; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, allSourceFiles, preferences) { + function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, allSourceFiles, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || symbolOriginInfo.type !== "export") { return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; 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; + var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, allSourceFiles, formatContext, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { @@ -90554,11 +91355,11 @@ var ts; return getContextualTypeFromParent(previousToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -90568,7 +91369,7 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo @@ -90583,15 +91384,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checker.getContextualType(parent); - case 200 /* BinaryExpression */: { + case 202 /* 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 266 /* CaseClause */: + case 269 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -90607,16 +91408,15 @@ 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 === 274 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); } 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 + var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) log("getCompletionData: Get current token: " + (ts.timestamp() - start)); start = ts.timestamp(); - // Completion not allowed inside comments, bail out if this is the case var insideComment = ts.isInComment(sourceFile, position, currentToken); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); var insideJsDocTagTypeExpression = false; @@ -90659,11 +91459,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { - currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 299 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 302 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -90681,7 +91481,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined); // 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 @@ -90690,7 +91490,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_1 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1)); } // Find the node where completion is requested on. @@ -90713,15 +91513,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; case 146 /* QualifiedName */: node = parent.left; break; - case 179 /* ImportType */: - case 210 /* MetaProperty */: + case 181 /* ImportType */: + case 212 /* MetaProperty */: node = parent; break; default: @@ -90734,7 +91534,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 === 185 /* PropertyAccessExpression */) { + if (parent && parent.kind === 187 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -90742,39 +91542,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 200 /* BinaryExpression */: - if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { - // It has a left-hand side, so we're not in an opening JSX tag. + case 202 /* BinaryExpression */: + if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: + case 260 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -90827,11 +91626,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: - case 294 /* JSDocReturnTag */: - case 296 /* JSDocTypeTag */: - case 298 /* JSDocTypedefTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: + case 297 /* JSDocReturnTag */: + case 299 /* JSDocTypeTag */: + case 301 /* JSDocTypedefTag */: return true; default: return false; @@ -90865,7 +91664,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -90889,27 +91688,31 @@ var ts; // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker, /*isForAccess*/ true)); + symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker)); } else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } } } function addPropertySymbol(symbol) { + // For a computed property with an accessible name like `Symbol.iterator`, + // we'll add a completion for the *name* `Symbol` instead of for the property. // 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 === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; - return leftName && typeChecker.getSymbolAtLocation(leftName); - }); - if (symbolSymbol) { - symbols.push(symbolSymbol); - symbolToOriginInfoMap[ts.getSymbolId(symbolSymbol)] = { type: "symbol-member" }; + var computedPropertyName = ts.firstDefined(symbol.declarations, function (decl) { return ts.tryCast(ts.getNameOfDeclaration(decl), ts.isComputedPropertyName); }); + if (computedPropertyName) { + var leftMostName = getLeftMostName(computedPropertyName.expression); // The completion is for `Symbol`, not `iterator`. + var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); + // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. + var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); + if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + symbols.push(firstAccessibleSymbol); + symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = { type: "symbol-member" }; + } } else { symbols.push(symbol); @@ -90993,10 +91796,10 @@ 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 !== 274 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { - for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { + for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { type: "this-type" }; symbols.push(symbol); @@ -91029,10 +91832,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 274 /* SourceFile */: - case 202 /* TemplateExpression */: - case 265 /* JsxExpression */: - case 213 /* Block */: + case 277 /* SourceFile */: + case 204 /* TemplateExpression */: + case 268 /* JsxExpression */: + case 216 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -91079,12 +91882,12 @@ var ts; return parentKind === 152 /* PropertyDeclaration */ || parentKind === 151 /* PropertySignature */ || parentKind === 149 /* Parameter */ || - parentKind === 232 /* VariableDeclaration */ || + parentKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 237 /* TypeAliasDeclaration */; + return parentKind === 240 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 208 /* AsExpression */; + return parentKind === 210 /* AsExpression */; } } return false; @@ -91187,11 +91990,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; + if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; } } return false; @@ -91201,36 +92004,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 187 /* CallExpression */ // func( a, | + return containingNodeKind === 189 /* 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 === 190 /* NewExpression */ // new C(a, | + || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 187 /* CallExpression */ // func( | + return containingNodeKind === 189 /* 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 */ + || containingNodeKind === 190 /* NewExpression */ // new C(a| + || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + return containingNodeKind === 185 /* 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 === 239 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 200 /* BinaryExpression */; // x = a| + return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 202 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: @@ -91268,16 +92071,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = hasIndexSignature(typeForObject); - typeMembers = getPropertiesForCompletion(typeForObject, typeChecker, /*isForAccess*/ false); + typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -91288,7 +92091,7 @@ 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 === 222 /* ForOfStatement */; + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 225 /* ForOfStatement */; if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); @@ -91335,7 +92138,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -91379,8 +92182,8 @@ 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); // TODO: GH#18217 - return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); + var type = typeChecker.getTypeAtLocation(baseTypeNode); + return type && typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); } @@ -91450,14 +92253,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: - case 263 /* JsxAttributes */: - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { + case 187 /* PropertyAccessExpression */: + case 266 /* JsxAttributes */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 262 /* JsxAttribute */) { + else if (parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91469,7 +92272,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 === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91479,8 +92282,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 265 /* JsxExpression */ && - parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { + parent.kind === 268 /* JsxExpression */ && + parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91488,7 +92291,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91508,49 +92311,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 232 /* VariableDeclaration */ || - containingNodeKind === 233 /* VariableDeclarationList */ || - containingNodeKind === 214 /* VariableStatement */ || - containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 235 /* VariableDeclaration */ || + containingNodeKind === 236 /* VariableDeclarationList */ || + containingNodeKind === 217 /* VariableStatement */ || + containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 182 /* BindingElement */; // var {x :html| + return containingNodeKind === 184 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 269 /* CatchClause */ || + return containingNodeKind === 272 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | - containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | + containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| + (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 248 /* ImportSpecifier */ || - containingNodeKind === 252 /* ExportSpecifier */ || - containingNodeKind === 246 /* NamespaceImport */; + return containingNodeKind === 251 /* ImportSpecifier */ || + containingNodeKind === 255 /* ExportSpecifier */ || + containingNodeKind === 249 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -91634,9 +92437,9 @@ 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 !== 270 /* PropertyAssignment */ && - m.kind !== 271 /* ShorthandPropertyAssignment */ && - m.kind !== 182 /* BindingElement */ && + if (m.kind !== 273 /* PropertyAssignment */ && + m.kind !== 274 /* ShorthandPropertyAssignment */ && + m.kind !== 184 /* BindingElement */ && m.kind !== 154 /* MethodDeclaration */ && m.kind !== 156 /* GetAccessor */ && m.kind !== 157 /* SetAccessor */) { @@ -91658,7 +92461,7 @@ var ts; // NOTE: if one only performs this step when m.name is an identifier, // things like '__proto__' are not filtered out. var name = ts.getNameOfDeclaration(m); - existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; + existingName = name && ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } @@ -91717,7 +92520,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 262 /* JsxAttribute */) { + if (attr.kind === 265 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -91824,47 +92627,28 @@ var ts; } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { - var jsDoc = getJsDocHavingNode(node).jsDoc; - if (!jsDoc) - return undefined; - for (var _i = 0, jsDoc_1 = jsDoc; _i < jsDoc_1.length; _i++) { - var _a = jsDoc_1[_i], pos = _a.pos, end = _a.end, tags = _a.tags; - if (!tags || position < pos || position > end) - continue; - for (var i = tags.length - 1; i >= 0; i--) { - var tag = tags[i]; - if (position >= tag.pos) { - return tag; - } - } - } + var jsdoc = ts.findAncestor(node, ts.isJSDoc); + return jsdoc && jsdoc.tags && (ts.rangeContainsPosition(jsdoc, position) ? ts.findLast(jsdoc.tags, function (tag) { return tag.pos < position; }) : undefined); } - function getJsDocHavingNode(node) { - if (!ts.isToken(node)) - return node; - switch (node.kind) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - // if the current token is var, let or const, skip the VariableDeclarationList - return node.parent.parent; - default: - return node.parent; - } + function getPropertiesForObjectExpression(contextualType, obj, checker) { + return contextualType.isUnion() + ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { + // 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. + return !(memberType.flags & 32764 /* Primitive */ || + checker.isArrayLikeType(memberType) || + ts.typeHasCallOrConstructSignatures(memberType, checker) || + checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); + })) + : contextualType.getApparentProperties(); } /** * Gets all properties on a type, but if that type is a union of several types, * excludes array-like types or callable/constructable types. */ - function getPropertiesForCompletion(type, checker, isForAccess) { - if (!(type.isUnion())) { - return ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); - } - // 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 & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); - }); - return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); + function getPropertiesForCompletion(type, checker) { + return type.isUnion() + ? ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") + : ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } /** * Returns the immediate owning class declaration of a context token, @@ -91873,7 +92657,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 300 /* SyntaxList */: + case 303 /* 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); @@ -91920,7 +92704,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -91929,12 +92713,16 @@ var ts; return ts.Debug.assertNever(triggerCharacter); } } + function binaryExpressionMayBeOpenTag(_a) { + var left = _a.left; + return ts.nodeIsMissing(left); + } function isStringLiteralOrTemplate(node) { switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: return true; default: return false; @@ -92068,7 +92856,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -92100,16 +92888,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 227 /* SwitchStatement */: - if (statement.kind === 223 /* ContinueStatement */) { + case 230 /* SwitchStatement */: + if (statement.kind === 226 /* ContinueStatement */) { return false; } // falls through - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -92119,24 +92907,17 @@ var ts; }); } function getModifierOccurrences(modifier, declaration) { - var modifierFlag = ts.modifierToFlag(modifier); - return ts.mapDefined(getNodesToSearchForModifier(declaration, modifierFlag), function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - var mod = ts.find(node.modifiers, function (m) { return m.kind === modifier; }); - ts.Debug.assert(!!mod); - return mod; - } - }); + return ts.mapDefined(getNodesToSearchForModifier(declaration, ts.modifierToFlag(modifier)), function (node) { return ts.findModifier(node, modifier); }); } function getNodesToSearchForModifier(declaration, modifierFlag) { // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: - case 213 /* Block */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: + case 216 /* Block */: + case 269 /* CaseClause */: + case 270 /* 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]); @@ -92146,10 +92927,10 @@ var ts; } case 155 /* Constructor */: case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -92182,7 +92963,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 === 218 /* DoStatement */) { + if (loopNode.kind === 221 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -92202,13 +92983,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -92580,12 +93361,13 @@ var ts; if (!markSeenDirectImport(direct)) { continue; } - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -92598,20 +93380,20 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -92621,7 +93403,7 @@ var ts; directImports.push(direct); } break; - case 179 /* ImportType */: + case 181 /* ImportType */: directImports.push(direct); break; default: @@ -92638,7 +93420,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -92693,7 +93475,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 243 /* ImportEqualsDeclaration */) { + if (decl.kind === 246 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -92703,7 +93485,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 179 /* ImportType */) { + if (decl.kind === 181 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -92718,17 +93500,17 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 250 /* ExportDeclaration */) { + if (decl.kind === 253 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -92778,7 +93560,7 @@ var ts; } } else { - var localSymbol = element.kind === 252 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 255 /* 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); @@ -92807,7 +93589,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 274 /* SourceFile */) { + if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -92837,7 +93619,8 @@ var ts; var map = ts.createMap(); for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { @@ -92854,7 +93637,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 === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -92869,15 +93652,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: { + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -92901,7 +93684,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 185 /* PropertyAccessExpression */) { + if (parent.kind === 187 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -93023,10 +93806,10 @@ var ts; // 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 === 232 /* VariableDeclaration */) { + if (parent.kind === 235 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -93035,15 +93818,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 248 /* ImportSpecifier */: + case 251 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -93076,21 +93859,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 274 /* SourceFile */) { + if (parent.kind === 277 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -93125,13 +93908,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* 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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; @@ -93147,8 +93930,7 @@ var ts; return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true }); } } - function findReferencedEntries(program, cancellationToken, sourceFiles, sourceFile, position, options) { - var node = ts.getTouchingPropertyName(sourceFile, position); + function findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options) { return ts.map(flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options)), toReferenceEntry); } FindAllReferences.findReferencedEntries = findReferencedEntries; @@ -93235,13 +94017,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 205 /* ClassExpression */) { + else if (node.kind === 207 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -93354,10 +94136,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 274 /* SourceFile */: + case 277 /* 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -93515,7 +94297,7 @@ var ts; this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; - /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ + /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { if (searchOptions === void 0) { searchOptions = {}; } // Note: if this is an external module symbol, the name doesn't include quotes. @@ -93598,6 +94380,24 @@ var ts; } } } + function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { + var importTracker = FindAllReferences.createImportTracker(sourceFiles, ts.arrayToSet(sourceFiles, function (f) { return f.fileName; }), checker, cancellationToken); + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers; + for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { + var importLocation = importSearches_2[_i][0]; + cb(importLocation); + } + for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) { + var indirectUser = indirectUsers_2[_b]; + for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { + var node = _d[_c]; + if (ts.isIdentifier(node) && checker.getSymbolAtLocation(node) === exportSymbol) { + cb(node); + } + } + } + } + Core.eachExportReference = eachExportReference; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; @@ -93630,9 +94430,9 @@ var ts; : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 184 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 182 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -93654,7 +94454,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 === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -93664,7 +94464,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, 235 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -93693,7 +94493,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 277 /* 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; @@ -93732,6 +94532,28 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function eachSignatureCall(signature, sourceFiles, checker, cb) { + if (!signature.name || !ts.isIdentifier(signature.name)) + return; + var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; + for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { + var name = _b[_a]; + if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) + continue; + var called = ts.climbPastPropertyAccess(name); + var call = called.parent; + if (!ts.isCallExpression(call) || call.expression !== called) + continue; + var referenceSymbol = checker.getSymbolAtLocation(name); + if (referenceSymbol && checker.getRootSymbols(referenceSymbol).some(function (s) { return s === symbol; })) { + cb(call); + } + } + } + } + Core.eachSignatureCall = eachSignatureCall; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos); }); @@ -93956,6 +94778,7 @@ var ts; function getReferenceForShorthandProperty(_a, search, state) { var flags = _a.flags, valueDeclaration = _a.valueDeclaration; var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + var name = valueDeclaration && ts.getNameOfDeclaration(valueDeclaration); /* * Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment * has two meanings: property name and property value. Therefore when we do findAllReference at the position where @@ -93963,8 +94786,8 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && search.includes(shorthandValueSymbol)) { - addReference(ts.getNameOfDeclaration(valueDeclaration), shorthandValueSymbol, state); + if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { @@ -94072,7 +94895,7 @@ var ts; if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -94092,7 +94915,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 213 /* Block */) { + if (body.kind === 216 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -94120,13 +94943,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 183 /* ArrayLiteralExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 185 /* ArrayLiteralExpression */: return true; default: return false; @@ -94224,20 +95047,20 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -94245,19 +95068,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* 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 274 /* SourceFile */: - return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); + case 277 /* SourceFile */: + return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -94459,16 +95282,17 @@ var ts; }); } ts.getEditsForFileRename = getEditsForFileRename; + // exported for tests function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var canonicalPath = getCanonicalFileName(path); - if (canonicalPath === canonicalOldPath) + if (getCanonicalFileName(path) === canonicalOldPath) return newFileOrDirPath; - var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + var suffix = ts.tryRemoveDirectoryPrefix(path, canonicalOldPath, getCanonicalFileName); return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; }; } + ts.getPathUpdater = getPathUpdater; function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) @@ -94539,9 +95363,10 @@ var ts; } } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { + var allFiles = program.getSourceFiles(); var _loop_3 = function (sourceFile) { - var newFromOld = oldToNew(sourceFile.fileName); - var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.fileName; + var newFromOld = oldToNew(sourceFile.path); + var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.path; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); var oldFromNew = newToOld(sourceFile.fileName); var oldImportFromPath = oldFromNew || sourceFile.fileName; @@ -94554,19 +95379,23 @@ var ts; var newAbsolute = oldToNew(oldAbsolute); return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); }, function (importLiteral) { + var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + // No need to update if it's an ambient module^M + if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. // TODO:GH#18217 ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) - : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); - // If neither the importing source file nor the imported file moved, do nothing. - return toImport === undefined || !toImport.updated && !importingSourceFileMoved - ? undefined - : ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, preferences); + : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew); + // Need an update if the imported file moved, or the importing file moved and was using a relative path. + return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text))) + ? ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, allFiles, preferences) + : undefined; }); }; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; + for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { + var sourceFile = allFiles_1[_i]; _loop_3(sourceFile); } } @@ -94576,12 +95405,10 @@ var ts; 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; + function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) { + if (importedModuleSymbol) { + // `find` should succeed because we checked for ambient modules before calling this function. + var oldFileName = ts.find(importedModuleSymbol.declarations, ts.isSourceFile).fileName; var newFileName = oldToNew(oldFileName); return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true }; } @@ -94657,7 +95484,8 @@ var ts; return getDefinitionInfoForIndexSignatures(node, typeChecker); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); - if (calledDeclaration) { + // Don't go to the component constructor definition for a JSX element, just go to the component definition. + if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && ts.isConstructorDeclaration(calledDeclaration))) { var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. @@ -94677,7 +95505,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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -94726,7 +95554,7 @@ var ts; */ function symbolMatchesSignature(s, calledDeclaration) { return s === calledDeclaration.symbol || s === calledDeclaration.symbol.parent || - ts.isVariableDeclaration(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; + !ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; } function getReferenceAtPosition(sourceFile, position, program) { var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); @@ -94819,11 +95647,11 @@ var ts; return true; } switch (declaration.kind) { - case 245 /* ImportClause */: - case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: return true; - case 248 /* ImportSpecifier */: - return declaration.parent.kind === 247 /* NamedImports */; + case 251 /* ImportSpecifier */: + return declaration.parent.kind === 250 /* NamedImports */; default: return false; } @@ -94877,7 +95705,7 @@ var ts; return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); } function findReferenceInPosition(refs, pos) { - return ts.find(refs, function (ref) { return ref.pos <= pos && pos <= ref.end; }); + return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; function getDefinitionInfoForFileReference(name, targetFileName) { @@ -94982,11 +95810,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: return [declaration]; - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -95007,16 +95835,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return withNode(tag.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -95146,7 +95974,7 @@ var ts; if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { return undefined; } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; @@ -95164,10 +95992,7 @@ var ts; var singleLineResult = "/** */"; return { newText: singleLineResult, caretOffset: 3 }; } - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - 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 indentationStr = getIndentationStringAtPosition(sourceFile, position); // 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) @@ -95175,8 +96000,7 @@ var ts; // * TODO: other tags. // * the closing comment line // * if the caret was directly in front of the object, then we add an extra line and indentation. - var preamble = "/**" + newLine + - indentationStr + " * "; + var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + @@ -95184,6 +96008,14 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function getIndentationStringAtPosition(sourceFile, position) { + var text = sourceFile.text; + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + var pos = lineStart; + for (; pos <= position && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) + ; + return text.slice(lineStart, pos); + } function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; @@ -95195,20 +96027,21 @@ var ts; function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: case 151 /* PropertySignature */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 237 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 240 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -95216,14 +96049,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 274 /* SourceFile */: + case 277 /* SourceFile */: return undefined; - case 239 /* ModuleDeclaration */: + case 242 /* 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 === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 200 /* BinaryExpression */: { + return commentOwner.parent.kind === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 202 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -95243,14 +96076,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return rightHandSide.parameters; - case 205 /* ClassExpression */: { + case 207 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -95279,15 +96112,12 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; _loop_4(sourceFile); } rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - return rawItems.map(createNavigateToItem); + return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } NavigateTo.getNavigateToItems = getNavigateToItems; function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { @@ -95302,23 +96132,23 @@ var ts; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 + // If the pattern has dots in it, then also see if the declaration container matches as well. + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } } else { - // If the pattern has dots in it, then also see if the declaration container matches as well. rawItems.push({ name: name, fileName: fileName, matchKind: match.kind, isCaseSensitive: match.isCaseSensitive, declaration: declaration }); } } } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 245 /* ImportClause */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - var importer = checker.getSymbolAtLocation(declaration.name); + case 248 /* ImportClause */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; default: @@ -95363,14 +96193,14 @@ 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 === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; + if (name && name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + return ts.emptyArray; } // Now, walk up our containers, adding all their names to the container array. var container = ts.getContainerNode(declaration); while (container) { if (!tryAddSingleDeclarationName(container, containers)) { - return undefined; + return ts.emptyArray; } container = ts.getContainerNode(container); } @@ -95395,7 +96225,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 */ // TODO: GH#18217 Just use `container ? ...` + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -95556,19 +96386,19 @@ var ts; addLeafNode(node); } break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addLeafNode(importClause); + addLeafNode(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -95579,8 +96409,8 @@ var ts; } } break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -95601,12 +96431,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -95616,9 +96446,9 @@ var ts; } endNode(); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -95626,18 +96456,18 @@ var ts; } endNode(); break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 252 /* ExportSpecifier */: - case 243 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: case 160 /* IndexSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -95645,7 +96475,7 @@ var ts; case 3 /* PrototypeProperty */: case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); - break; + return; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: @@ -95721,7 +96551,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -95731,7 +96561,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -95761,7 +96591,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -95769,16 +96599,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -95788,16 +96618,16 @@ var ts; } } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -95835,25 +96665,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 274 /* SourceFile */: - case 237 /* TypeAliasDeclaration */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 277 /* SourceFile */: + case 240 /* TypeAliasDeclaration */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return true; case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -95863,8 +96693,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; @@ -95875,7 +96705,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; + return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; }); } } @@ -95932,7 +96762,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 === 239 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -95943,16 +96773,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 === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 + return decl.body.kind === 242 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -95962,16 +96792,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 === 232 /* VariableDeclaration */) { + else if (node.parent.kind === 235 /* 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 === 200 /* BinaryExpression */ && + else if (node.parent.kind === 202 /* 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 === 270 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 273 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -95984,9 +96814,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: return true; default: return false; @@ -96042,10 +96872,7 @@ var ts; }); // Delete or replace the first import. if (newImportDecls.length === 0) { - changeTracker.deleteNode(sourceFile, oldImportDecls[0], { - useNonAdjustedStartPosition: true, - useNonAdjustedEndPosition: false, - }); + changeTracker.delete(sourceFile, oldImportDecls[0]); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. @@ -96057,7 +96884,7 @@ var ts; } // Delete any subsequent imports. for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + changeTracker.delete(sourceFile, oldImportDecls[i]); } } } @@ -96353,7 +97180,7 @@ var ts; var currentLineStart = lineStarts[i]; var lineEnd = i + 1 === lineStarts.length ? sourceFile.getEnd() : lineStarts[i + 1] - 1; var lineText = sourceFile.text.substring(currentLineStart, lineEnd); - var result = lineText.match(/^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/); + var result = isRegionDelimiter(lineText); if (!result || ts.isInComment(sourceFile, currentLineStart)) { continue; } @@ -96371,6 +97198,10 @@ var ts; } } } + var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + function isRegionDelimiter(lineText) { + return regionDelimiterRegExp.exec(lineText); + } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); if (!comments) @@ -96378,11 +97209,19 @@ var ts; var firstSingleLineCommentStart = -1; var lastSingleLineCommentEnd = -1; var singleLineCommentCount = 0; + var sourceText = sourceFile.getFullText(); for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { var _a = comments_1[_i], kind = _a.kind, pos = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { case 2 /* SingleLineCommentTrivia */: + // never fold region delimiters into single-line comment regions + var commentText = sourceText.slice(pos, end); + if (isRegionDelimiter(commentText)) { + combineAndAddMultipleSingleLineComments(); + singleLineCommentCount = 0; + break; + } // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (singleLineCommentCount === 0) { @@ -96413,24 +97252,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* 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 218 /* DoStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 269 /* CatchClause */: + case 221 /* DoStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 272 /* CatchClause */: return spanForNode(n.parent); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -96445,16 +97284,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanForNode(n.parent); - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 241 /* CaseBlock */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 244 /* CaseBlock */: return spanForNode(n); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -96528,7 +97367,6 @@ var ts; if (!candidateMatch) { return undefined; } - candidateContainers = candidateContainers || []; // -1 because the last part was checked against the name, and only the rest // of the parts are checked against the container. if (dotSeparatedSegments.length - 1 > candidateContainers.length) { @@ -97287,21 +98125,12 @@ var ts; (function (ts) { var Rename; (function (Rename) { - function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); + function getRenameInfo(program, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }) : undefined; return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); - function isDefinedInLibraryFile(declaration) { - if (!defaultLibFileName) { - return false; - } - var sourceFile = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - return canonicalName === getCanonicalDefaultLibName(); - } } Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { @@ -97395,7 +98224,7 @@ var ts; InvocationKind[InvocationKind["Call"] = 0] = "Call"; InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; })(InvocationKind || (InvocationKind = {})); - function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { + function getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -97403,6 +98232,12 @@ var ts; // We are at the beginning of the file return undefined; } + if (shouldCarefullyCheckContext(triggerReason)) { + // In the middle of a string, don't provide signature help unless the user explicitly requested it. + if (ts.isInString(sourceFile, position, startingToken)) { + return undefined; + } + } var argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); if (!argumentInfo) return undefined; @@ -97421,6 +98256,10 @@ var ts; return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + function shouldCarefullyCheckContext(reason) { + // Only need to be careful if the user typed a character and signature help wasn't showing. + return !!reason && reason.kind === "characterTyped"; + } function getCandidateInfo(argumentInfo, checker) { var invocation = argumentInfo.invocation; if (invocation.kind === 0 /* Call */) { @@ -97538,10 +98377,10 @@ var ts; return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -97690,7 +98529,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -97854,7 +98693,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var decl = ts.getDeclarationOfJSInitializer(node); if (decl) { var symbol_2 = decl.symbol; @@ -97864,7 +98703,7 @@ var ts; } } // falls through if no diagnostic was created - case 234 /* FunctionDeclaration */: + case 237 /* 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)); @@ -97894,11 +98733,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); // TODO: GH#18217 - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -97915,12 +98754,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -97943,7 +98782,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -97988,7 +98827,7 @@ var ts; if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return "parameter" /* parameterElement */; } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { return "const" /* constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { @@ -98031,11 +98870,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 257 /* JsxOpeningElement */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -98075,7 +98914,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 185 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 187 /* 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)) { @@ -98096,7 +98935,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 190 /* 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 @@ -98183,7 +99022,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 207 /* 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 @@ -98217,7 +99056,7 @@ var ts; } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } @@ -98227,7 +99066,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -98265,7 +99104,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 237 /* TypeAliasDeclaration */) { + else if (declaration.kind === 240 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -98282,7 +99121,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 273 /* EnumMember */) { + if (declaration.kind === 276 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -98312,17 +99151,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 249 /* ExportAssignment */: + case 252 /* 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 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -98331,7 +99170,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 243 /* ImportEqualsDeclaration */) { + if (declaration.kind === 246 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -98409,10 +99248,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 === 274 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -98524,16 +99363,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 192 /* FunctionExpression */) { + if (declaration.kind === 194 /* FunctionExpression */) { return true; } - if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* FunctionDeclaration */) { + if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* 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 === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { + if (parent.kind === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { return false; } } @@ -98842,10 +99681,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 262 /* JsxAttribute */: - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 265 /* JsxAttribute */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* 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 */; } @@ -99326,44 +100165,44 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 220 /* ForStatement */; + return context.contextNode.kind === 223 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 171 /* ConditionalType */: - case 208 /* AsExpression */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 173 /* ConditionalType */: + case 210 /* AsExpression */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 161 /* TypePredicate */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 182 /* BindingElement */: + case 184 /* BindingElement */: // equals in type X = ... - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: // equal in p = 0; case 149 /* Parameter */: - case 273 /* EnumMember */: + case 276 /* 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 221 /* ForInStatement */: + case 224 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] 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 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; @@ -99379,19 +100218,19 @@ var ts; return contextKind === 152 /* PropertyDeclaration */ || contextKind === 151 /* PropertySignature */ || contextKind === 149 /* Parameter */ || - contextKind === 232 /* VariableDeclaration */ || + contextKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 201 /* ConditionalExpression */ || - context.contextNode.kind === 171 /* ConditionalType */; + return context.contextNode.kind === 203 /* ConditionalExpression */ || + context.contextNode.kind === 173 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 180 /* ObjectBindingPattern */ || - context.contextNode.kind === 177 /* MappedType */ || + return context.contextNode.kind === 182 /* ObjectBindingPattern */ || + context.contextNode.kind === 179 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -99417,17 +100256,17 @@ var ts; return true; } switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 184 /* ObjectLiteralExpression */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 186 /* ObjectLiteralExpression */: + case 243 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -99435,13 +100274,13 @@ var ts; case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: case 158 /* CallSignature */: - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: case 155 /* Constructor */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -99450,40 +100289,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; + return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: case 166 /* TypeLiteral */: - case 239 /* ModuleDeclaration */: - case 250 /* ExportDeclaration */: - case 251 /* NamedExports */: - case 244 /* ImportDeclaration */: - case 247 /* NamedImports */: + case 242 /* ModuleDeclaration */: + case 253 /* ExportDeclaration */: + case 254 /* NamedExports */: + case 247 /* ImportDeclaration */: + case 250 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 269 /* CatchClause */: - case 240 /* ModuleBlock */: - case 227 /* SwitchStatement */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 272 /* CatchClause */: + case 243 /* ModuleBlock */: + case 230 /* SwitchStatement */: return true; - case 213 /* Block */: { + case 216 /* 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 !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { return true; } } @@ -99492,31 +100331,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - 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 */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 229 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 269 /* CatchClause */: + case 272 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 184 /* ObjectLiteralExpression */; + return context.contextNode.kind === 186 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 187 /* CallExpression */; + return context.contextNode.kind === 189 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 188 /* NewExpression */; + return context.contextNode.kind === 190 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -99528,28 +100367,28 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 193 /* ArrowFunction */; + return context.contextNode.kind === 195 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 179 /* ImportType */; + return context.contextNode.kind === 181 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; + return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; + return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 262 /* JsxAttribute */; + return context.nextTokenParent.kind === 265 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 262 /* JsxAttribute */; + return context.contextNode.kind === 265 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 256 /* JsxSelfClosingElement */; + return context.contextNode.kind === 259 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -99567,14 +100406,14 @@ var ts; return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 239 /* ModuleDeclaration */; + return context.contextNode.kind === 242 /* ModuleDeclaration */; } function isObjectTypeContext(context) { return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -99588,21 +100427,21 @@ var ts; } switch (parent.kind) { 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 192 /* TypeAssertionExpression */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -99613,16 +100452,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 190 /* TypeAssertionExpression */; + return context.contextNode.kind === 192 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 209 /* NonNullExpression */; + return context.contextNode.kind === 211 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -99856,17 +100695,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 274 /* SourceFile */: - case 213 /* Block */: - case 240 /* ModuleBlock */: + return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 277 /* SourceFile */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -100089,10 +100928,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - 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 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; case 156 /* GetAccessor */: return 125 /* GetKeyword */; case 157 /* SetAccessor */: return 136 /* SetKeyword */; case 154 /* MethodDeclaration */: @@ -100102,7 +100941,10 @@ var ts; // falls through case 152 /* PropertyDeclaration */: case 149 /* Parameter */: - return ts.getNameOfDeclaration(node).kind; + var name = ts.getNameOfDeclaration(node); + if (name) { + return name.kind; + } } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { @@ -100146,15 +100988,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 177 /* MappedType */) { + if (container.kind !== 179 /* MappedType */) { return false; } break; @@ -100254,7 +101096,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -100622,56 +101464,47 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword + tokenAtPosition) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } + var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); + if (jsdoc) + tokenAtPosition = jsdoc.parent; var tokenStart = tokenAtPosition.getStart(sourceFile); if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } - if (precedingToken === undefined) { - precedingToken = ts.findPrecedingToken(position, sourceFile); - } + precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); - var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? - trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : - trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; - if (commentRanges) { - for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { - var range = commentRanges_1[_i]; - // The end marker of a single-line comment does not include the newline character. - // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for closed multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // However, unterminated multi-line comments *do* contain their end. - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - // - if ((range.pos < position && position < range.end || - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()))) { - return (range.kind === 3 /* MultiLineCommentTrivia */ || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; - } - } - } - return undefined; + var commentRanges = ts.concatenate(trailingRangesOfPreviousToken, leadingCommentRangesOfNextToken); + return commentRanges && ts.find(commentRanges, function (range) { return ts.rangeContainsPositionExclusive(range, position) || + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -100679,8 +101512,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -100785,9 +101618,9 @@ var ts; if (options.indentStyle === ts.IndentStyle.None) { return 0; } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword - if (enclosingCommentRange) { + var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -100805,7 +101638,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* 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 */) { @@ -100961,7 +101794,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 === 274 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -101009,7 +101842,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -101027,13 +101860,13 @@ var ts; switch (node.parent.kind) { case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.parent.properties; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return node.parent.elements; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: @@ -101044,21 +101877,21 @@ var ts; return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 188 /* NewExpression */: - case 187 /* CallExpression */: { + case 190 /* NewExpression */: + case 189 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -101098,10 +101931,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: node = node.expression; break; default: @@ -101166,82 +101999,82 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - 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 219 /* ExpressionStatement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 185 /* ArrayLiteralExpression */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 177 /* MappedType */: + case 179 /* 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 244 /* CaseBlock */: + case 270 /* DefaultClause */: + case 269 /* CaseClause */: + case 193 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 217 /* VariableStatement */: + case 252 /* ExportAssignment */: + case 228 /* ReturnStatement */: + case 203 /* ConditionalExpression */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: + case 259 /* JsxSelfClosingElement */: + case 268 /* 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 175 /* ParenthesizedType */: + case 191 /* TaggedTemplateExpression */: + case 199 /* AwaitExpression */: + case 254 /* NamedExports */: + case 250 /* NamedImports */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 152 /* PropertyDeclaration */: return true; - case 232 /* VariableDeclaration */: - case 270 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 235 /* VariableDeclaration */: + case 273 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } 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 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: - case 193 /* ArrowFunction */: + case 195 /* 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 */: + return childKind !== 216 /* Block */; + case 253 /* ExportDeclaration */: + return childKind !== 254 /* NamedExports */; + case 247 /* ImportDeclaration */: + return childKind !== 248 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); + case 258 /* JsxElement */: + return childKind !== 261 /* JsxClosingElement */; + case 262 /* JsxFragment */: + return childKind !== 264 /* JsxClosingFragment */; + case 172 /* IntersectionType */: + case 171 /* UnionType */: if (childKind === 166 /* TypeLiteral */) { return false; } @@ -101253,17 +102086,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: { - if (parent.kind !== 213 /* Block */) { + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: { + if (parent.kind !== 216 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 194 /* FunctionExpression */ || grandParent.kind === 237 /* FunctionDeclaration */); } - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return true; default: return false; @@ -101392,7 +102225,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 === 184 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -101408,8 +102241,8 @@ var ts; this.formatContext = formatContext; this.changes = []; this.newFiles = []; - this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map + this.deletedNodes = []; } ChangeTracker.fromContext = function (context) { return new ChangeTracker(ts.getNewLineOrDefaultFromHost(context.host, context.formatContext.options), context.formatContext); @@ -101423,13 +102256,11 @@ var ts; this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); return this; }; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { - if (options === void 0) { options = {}; } - var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); - var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); - return this; + ChangeTracker.prototype.delete = function (sourceFile, node) { + this.deletedNodes.push({ sourceFile: sourceFile, node: node, }); + }; + ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { + this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } @@ -101444,30 +102275,6 @@ var ts; 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) { - ts.Debug.fail("node is not a list element"); - return this; - } - var index = ts.indexOfNode(containingList, node); - if (index < 0) { - return this; - } - if (containingList.length === 1) { - this.deleteNode(sourceFile, node); - return this; - } - // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. - // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. - ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice"); - this.deletedNodesInLists.add(node); - this.deleteRange(sourceFile, { - pos: startPositionToDeleteNodeInList(sourceFile, node), - end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), - }); - return this; - }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); @@ -101533,7 +102340,7 @@ var ts; // If so, we do not want to separate the node from its comment if we can. // Otherwise, add an extra new line immediately before the error span. var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); - var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); @@ -101557,7 +102364,7 @@ var ts; } } else { - endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -101576,6 +102383,9 @@ var ts; else if (ts.isParameter(before)) { return {}; } + else if (ts.isStringLiteral(before) && ts.isImportDeclaration(before.parent) || ts.isNamedImports(before)) { + return { suffix: ", " }; + } return ts.Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { @@ -101635,6 +102445,9 @@ var ts; var endPosition = this.insertNodeAfterWorker(sourceFile, after, newNode); this.insertNodeAt(sourceFile, endPosition, newNode, this.getInsertNodeAfterOptions(sourceFile, after)); }; + ChangeTracker.prototype.insertNodeAtEndOfList = function (sourceFile, list, newNode) { + this.insertNodeAt(sourceFile, list.end, newNode, { prefix: ", " }); + }; ChangeTracker.prototype.insertNodesAfter = function (sourceFile, after, newNodes) { var endPosition = this.insertNodeAfterWorker(sourceFile, after, ts.first(newNodes)); this.insertNodesAt(sourceFile, endPosition, newNodes, this.getInsertNodeAfterOptions(sourceFile, after)); @@ -101655,32 +102468,34 @@ var ts; return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { - if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) { - return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + switch (node.kind) { + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + case 235 /* VariableDeclaration */: + case 9 /* StringLiteral */: + case 71 /* Identifier */: + return { prefix: ", " }; + case 273 /* PropertyAssignment */: + return { suffix: "," + this.newLineCharacter }; + case 84 /* ExportKeyword */: + return { prefix: " " }; + case 149 /* Parameter */: + return {}; + default: + ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it + return { suffix: this.newLineCharacter }; } - else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { - return { suffix: this.newLineCharacter }; - } - else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { - return { prefix: ", " }; - } - else if (ts.isPropertyAssignment(node)) { - return { suffix: "," + this.newLineCharacter }; - } - else if (ts.isParameter(node)) { - return {}; - } - return ts.Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 193 /* ArrowFunction */) { + if (node.kind === 195 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); - this.deleteNode(sourceFile, arrow); + deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` @@ -101688,14 +102503,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 !== 213 /* Block */) { + if (node.body.kind !== 216 /* 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 === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -101721,7 +102536,7 @@ var ts; if (index !== containingList.length - 1) { // any element except the last one // use next sibling as an anchor - var nextToken = ts.getTokenAtPosition(sourceFile, after.end, /*includeJsDocComment*/ false); + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); if (nextToken && isSeparator(after, nextToken)) { // for list // a, b, c @@ -101826,14 +102641,25 @@ var ts; } }); }; - ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () { + ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - this.deletedNodesInLists.forEach(function (node) { + var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var _loop_10 = function (sourceFile, node) { + if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { + deleteDeclaration.deleteDeclaration(this_1, deletedNodesInLists, sourceFile, node); + } + }; + var this_1 = this; + for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { + var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; + _loop_10(sourceFile, node); + } + deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (node !== ts.last(list)) return; - var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2); + var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !deletedNodesInLists.has(n); }, list.length - 2); if (lastNonDeletedIndex !== -1) { _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) }); } @@ -101846,8 +102672,8 @@ var ts; * so we can only call this once and can't get the non-formatted text separately. */ ChangeTracker.prototype.getChanges = function (validate) { + this.finishDeleteDeclarations(); this.finishClassesWithNodesInsertedAtStart(); - this.finishTrailingCommaAfterDeletingNodesInList(); 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; @@ -101876,14 +102702,14 @@ var ts; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); - var _loop_10 = function (i) { + var _loop_11 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_10(i); + _loop_11(i); } var textChanges = normalized.map(function (c) { return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate)); @@ -101944,8 +102770,8 @@ var ts; })(changesToText || (changesToText = {})); function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { - var change = changes[i]; - text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + var _a = changes[i], span = _a.span, newText = _a.newText; + text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); } return text; } @@ -102147,6 +102973,177 @@ var ts; 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 `[` } + var deleteDeclaration; + (function (deleteDeclaration_1) { + function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { + switch (node.kind) { + case 149 /* Parameter */: { + var oldFunction = node.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, // 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. + ts.suppressLeadingAndTrailingTrivia(newFunction); + changes.replaceNode(sourceFile, oldFunction, newFunction); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 247 /* ImportDeclaration */: + deleteNode(changes, sourceFile, node, + // For first import, leave header comment in place + node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); + break; + case 184 /* BindingElement */: + var pattern = node.parent; + var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + if (preserveComma) { + deleteNode(changes, sourceFile, node); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 235 /* VariableDeclaration */: + deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); + break; + case 148 /* TypeParameter */: { + var typeParameters = ts.getEffectiveTypeParameterDeclarations(node.parent); + if (typeParameters.length === 1) { + var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; + var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1); + var nextToken = ts.getTokenAtPosition(sourceFile, end); + ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); + ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); + changes.deleteNodeRange(sourceFile, previousToken, nextToken); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 251 /* ImportSpecifier */: + var namedImports = node.parent; + if (namedImports.elements.length === 1) { + deleteImportBinding(changes, sourceFile, namedImports); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 249 /* NamespaceImport */: + deleteImportBinding(changes, sourceFile, node); + break; + default: + if (ts.isImportClause(node.parent) && node.parent.name === node) { + deleteDefaultImport(changes, sourceFile, node.parent); + } + else if (ts.isCallLikeExpression(node.parent)) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + else { + deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + } + } + } + deleteDeclaration_1.deleteDeclaration = deleteDeclaration; + function deleteDefaultImport(changes, sourceFile, importClause) { + if (!importClause.namedBindings) { + // Delete the whole import + deleteNode(changes, sourceFile, importClause.parent); + } + else { + // import |d,| * as ns from './file' + var start = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26 /* CommaToken */) { + // shift first non-whitespace position after comma to the start position of the node + var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); + changes.deleteRange(sourceFile, { pos: start, end: end }); + } + else { + deleteNode(changes, sourceFile, importClause.name); + } + } + } + function deleteImportBinding(changes, sourceFile, node) { + if (node.parent.name) { + // Delete named imports while preserving the default import + // import d|, * as ns| from './file' + // import d|, { a }| from './file' + var previousToken = ts.Debug.assertDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1)); + changes.deleteRange(sourceFile, { pos: previousToken.getStart(sourceFile), end: node.end }); + } + else { + // Delete the entire import declaration + // |import * as ns from './file'| + // |import { a } from './file'| + var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + deleteNode(changes, sourceFile, importDecl); + } + } + function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { + var parent = node.parent; + if (parent.kind === 272 /* CatchClause */) { + // TODO: There's currently no unused diagnostic for this, could be a suggestion + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + return; + } + if (parent.declarations.length !== 1) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + return; + } + var gp = parent.parent; + switch (gp.kind) { + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: + changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); + break; + case 223 /* ForStatement */: + deleteNode(changes, sourceFile, parent); + break; + case 217 /* VariableStatement */: + deleteNode(changes, sourceFile, gp); + break; + default: + ts.Debug.assertNever(gp); + } + } + })(deleteDeclaration || (deleteDeclaration = {})); + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + // Exported for tests only! (TODO: improve tests to not need this) + function deleteNode(changes, sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + changes.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + textChanges_3.deleteNode = deleteNode; + function deleteNodeInList(changes, deletedNodesInLists, sourceFile, node) { + var containingList = ts.Debug.assertDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile)); + var index = ts.indexOfNode(containingList, node); + ts.Debug.assert(index !== -1); + if (containingList.length === 1) { + deleteNode(changes, sourceFile, node); + return; + } + // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. + // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. + ts.Debug.assert(!deletedNodesInLists.has(node), "Deleting a node twice"); + deletedNodesInLists.add(node); + changes.deleteRange(sourceFile, { + pos: startPositionToDeleteNodeInList(sourceFile, node), + end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), + }); + } })(textChanges = ts.textChanges || (ts.textChanges = {})); })(ts || (ts = {})); /* @internal */ @@ -102202,15 +103199,14 @@ var ts; function createCombinedCodeActions(changes, commands) { return { changes: changes, commands: commands }; } + codefix.createCombinedCodeActions = createCombinedCodeActions; function createFileTextChanges(fileName, textChanges) { return { fileName: fileName, textChanges: textChanges }; } codefix.createFileTextChanges = createFileTextChanges; function codeFixAll(context, errorCodes, use) { var commands = []; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { - return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); - }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); }); return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } codefix.codeFixAll = codeFixAll; @@ -102223,6 +103219,7 @@ var ts; } } } + codefix.eachDiagnostic = eachDiagnostic; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -102273,7 +103270,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, }); function makeChange(changeTracker, sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var decorator = ts.findAncestor(token, ts.isDecorator); ts.Debug.assert(!!decorator, "Expected position to be owned by a decorator."); var replacement = ts.createCall(decorator.expression, /*typeArguments*/ undefined, /*argumentsArray*/ undefined); @@ -102305,7 +103302,7 @@ var ts; }); }, }); function getDeclaration(file, pos) { - var name = ts.getTokenAtPosition(file, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(file, pos); // For an arrow function with no name, 'name' lands on the first parameter. return ts.tryCast(ts.isParameter(name.parent) ? name.parent.parent : name.parent, parameterShouldGetTypeFromJSDoc); } @@ -102352,24 +103349,24 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 232 /* VariableDeclaration */ || + node.kind === 235 /* VariableDeclaration */ || node.kind === 151 /* PropertySignature */ || node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 162 /* TypeReference */: return transformJSDocTypeReference(node); @@ -102393,7 +103390,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 288 /* 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); @@ -102459,8 +103456,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, err) { return doChange(changes, err.file, err.start, context.program.getTypeChecker()); }); }, }); function doChange(changes, sourceFile, position, checker) { - var deletedNodes = []; - var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false)); + var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; @@ -102469,20 +103465,20 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); + changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { ts.copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 - deleteNode(precedingNode); + changes.delete(sourceFile, precedingNode); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + changes.delete(sourceFile, ctorDeclaration); } break; } @@ -102492,22 +103488,6 @@ var ts; ts.copyComments(ctorDeclaration, newClassDeclaration, sourceFile); // Because the preceding node could be touched, we need to insert nodes before delete nodes. changes.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration); - for (var _i = 0, deletedNodes_1 = deletedNodes; _i < deletedNodes_1.length; _i++) { - var _a = deletedNodes_1[_i], node = _a.node, inList = _a.inList; - if (inList) { - changes.deleteNodeInList(sourceFile, node); - } - else { - changes.deleteNode(sourceFile, node); - } - } - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - // If parent node has already been deleted, do nothing - if (!deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n.node); })) { - deletedNodes.push({ node: node, inList: inList }); - } - } function createClassElementsFromSymbol(symbol) { var memberElements = []; // all instance members are stored in the "member" array of symbol @@ -102545,15 +103525,15 @@ 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 === 216 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 219 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); + changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 192 /* FunctionExpression */: { + case 194 /* 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, @@ -102561,12 +103541,12 @@ var ts; ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 193 /* ArrowFunction */: { + case 195 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 213 /* Block */) { + if (arrowFunctionBody.kind === 216 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -102594,7 +103574,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { @@ -102658,10 +103638,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -102714,20 +103694,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 187 /* CallExpression */: { + case 189 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -102769,8 +103749,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: { + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -102793,7 +103773,7 @@ var ts; if (ts.isExportsOrModuleExportsOrAlias(sourceFile, left)) { if (ts.isExportsOrModuleExportsOrAlias(sourceFile, right)) { // `const alias = module.exports;` or `module.exports = alias;` can be removed. - changes.deleteNode(sourceFile, assignment.parent); + changes.delete(sourceFile, assignment.parent); } else { var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right) @@ -102824,10 +103804,10 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 271 /* ShorthandPropertyAssignment */: - case 272 /* SpreadAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 275 /* SpreadAssignment */: return undefined; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); @@ -102884,7 +103864,7 @@ var ts; changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); if (semi) - changes.deleteNode(sourceFile, semi, { useNonAdjustedEndPosition: true }); + changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` @@ -102895,7 +103875,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -102903,10 +103883,10 @@ var ts; } } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -102924,7 +103904,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: { + case 182 /* 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 @@ -102935,7 +103915,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 181 /* ArrayBindingPattern */: { + case 183 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -103018,11 +103998,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node; - case 182 /* BindingElement */: + case 184 /* BindingElement */: return parent.propertyName !== node; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -103081,7 +104061,7 @@ var ts; }); }, }); function getQualifiedName(sourceFile, pos) { - var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ true), ts.isQualifiedName); + var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), ts.isQualifiedName); ts.Debug.assert(!!qualifiedName, "Expected position to be owned by a qualified name."); return ts.isIdentifier(qualifiedName.left) ? qualifiedName : undefined; } @@ -103126,7 +104106,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -103154,7 +104134,7 @@ var ts; } } function getHeritageClauseSymbolTable(classDeclaration, checker) { - var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var heritageClauseNode = ts.getEffectiveBaseTypeNode(classDeclaration); if (!heritageClauseNode) return ts.createSymbolTable(); var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); @@ -103168,42 +104148,109 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var ChangeTracker = ts.textChanges.ChangeTracker; + codefix.importFixId = "fixMissingImport"; + var errorCodes = [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, + ts.Diagnostics.Cannot_find_namespace_0.code, + 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, + ]; codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics.Cannot_find_name_0.code, - ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, - ts.Diagnostics.Cannot_find_namespace_0.code, - 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: 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, + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span; + var info = getFixesInfo(context, errorCode, span.start); + if (!info) + return undefined; + var fixes = info.fixes, symbolName = info.symbolName; + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference); }); + }, + fixIds: [codefix.importFixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, preferences = context.preferences; + // Namespace fixes don't conflict, so just build a list. + var addToNamespace = []; + // Keys are import clause node IDs. + var addToExisting = ts.createMap(); + // Keys are module specifiers. + var newImports = ts.createMap(); + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getFixesInfo(context, diag.code, diag.start); + if (!info || !info.fixes.length) + return; + var fixes = info.fixes, symbolName = info.symbolName; + var fix = ts.first(fixes); + switch (fix.kind) { + case 0 /* UseNamespace */: + addToNamespace.push(fix); + break; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + var key = String(ts.getNodeId(importClause)); + var entry = addToExisting.get(key); + if (!entry) { + addToExisting.set(key, entry = { importClause: importClause, defaultImport: undefined, namedImports: [] }); + } + if (importKind === 0 /* Named */) { + ts.pushIfUnique(entry.namedImports, symbolName); + } + else { + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + } + break; + } + case 2 /* AddNew */: { + var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind; + var entry = newImports.get(moduleSpecifier); + if (!entry) { + newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined }); + } + switch (importKind) { + case 1 /* Default */: + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + break; + case 0 /* Named */: + ts.pushIfUnique(entry.namedImports, symbolName); + break; + case 3 /* Equals */: + case 2 /* Namespace */: + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; + break; + } + break; + } + default: + ts.Debug.assertNever(fix); + } + }); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) { + var fix = addToNamespace_1[_i]; + addNamespaceQualifier(changes, sourceFile, fix); + } + addToExisting.forEach(function (_a) { + var importClause = _a.importClause, defaultImport = _a.defaultImport, namedImports = _a.namedImports; + doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports); + }); + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + newImports.forEach(function (imports, moduleSpecifier) { + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports); + }); + })); + }, }); - function createCodeAction(descriptionDiagnostic, diagnosticArgs, changes) { - // TODO: GH#20315 - return codefix.createCodeFixActionNoFixId("import", changes, [descriptionDiagnostic].concat(diagnosticArgs)); - } - function convertToImportCodeFixContext(context, symbolToken, symbolName) { - var program = context.program; - var checker = program.getTypeChecker(); - return { - host: context.host, - formatContext: context.formatContext, - sourceFile: context.sourceFile, - program: program, - checker: checker, - compilerOptions: program.getCompilerOptions(), - getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), - symbolName: symbolName, - symbolToken: symbolToken, - preferences: context.preferences, - }; - } + // Sorted with the preferred fix coming first. + var ImportFixKind; + (function (ImportFixKind) { + ImportFixKind[ImportFixKind["UseNamespace"] = 0] = "UseNamespace"; + ImportFixKind[ImportFixKind["AddToExisting"] = 1] = "AddToExisting"; + ImportFixKind[ImportFixKind["AddNew"] = 2] = "AddNew"; + })(ImportFixKind || (ImportFixKind = {})); var ImportKind; (function (ImportKind) { ImportKind[ImportKind["Named"] = 0] = "Named"; @@ -103211,13 +104258,13 @@ var ts; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; })(ImportKind || (ImportKind = {})); - function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, symbolToken, preferences) { + function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, allSourceFiles, formatContext, symbolToken, preferences) { var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, checker, allSourceFiles); ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, exportInfos, host, preferences)).moduleSpecifier; - var ctx = { host: host, program: program, checker: checker, compilerOptions: compilerOptions, sourceFile: sourceFile, formatContext: formatContext, symbolName: symbolName, getCanonicalFileName: getCanonicalFileName, symbolToken: symbolToken, preferences: preferences }; - return { moduleSpecifier: moduleSpecifier, codeAction: ts.first(getCodeActionsForImport(exportInfos, ctx)) }; + var fix = ts.first(getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences)); + return { moduleSpecifier: moduleSpecifier, codeAction: codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences)) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, checker, allSourceFiles) { @@ -103237,23 +104284,16 @@ var ts; }); return result; } - function getCodeActionsForImport(exportInfos, context) { - var result = []; - getCodeActionsForImport_separateExistingAndNew(exportInfos, context, result, result); - return result; + function getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences) { + var checker = program.getTypeChecker(); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var useNamespace = tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker); + var addToExisting = tryAddToExistingImport(existingImports); + // Don't bother providing an action to add a new import if we can add to an existing one. + var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); + return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); } - function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - 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) { + function tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -103270,29 +104310,31 @@ var ts; 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); + var moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { + return { kind: 0 /* UseNamespace */, namespacePrefix: namespace.text, symbolToken: symbolToken }; } } }); } - function tryAddToExistingImport(existingImports, context) { + function tryAddToExistingImport(existingImports) { 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); - } - } + if (declaration.kind !== 247 /* ImportDeclaration */) + return undefined; + var importClause = declaration.importClause; + if (!importClause) + return undefined; + var name = importClause.name, namedBindings = importClause.namedBindings; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + ? { kind: 1 /* AddToExisting */, importClause: importClause, importKind: importKind } + : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 244 /* ImportDeclaration */) { + if (declaration.kind === 247 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -103303,141 +104345,61 @@ var ts; var imports = _b.imports; return ts.mapDefined(imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } - function getCodeActionForNewImport(context, _a) { - var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; - var sourceFile = context.sourceFile, symbolName = context.symbolName, preferences = context.preferences; - var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); - var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifierWithoutQuotes, ts.getQuotePreference(sourceFile, preferences)); - var importDecl = importKind !== 3 /* Equals */ - ? ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClauseOfKind(importKind, symbolName), quotedModuleSpecifier) - : ts.createImportEqualsDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createIdentifier(symbolName), ts.createExternalModuleReference(quotedModuleSpecifier)); - var changes = ChangeTracker.with(context, function (t) { return ts.insertImport(t, sourceFile, importDecl); }); - // 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 separating code and import statements. - return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); - } - function createImportClauseOfKind(kind, symbolName) { - var id = ts.createIdentifier(symbolName); - switch (kind) { - case 1 /* Default */: - return ts.createImportClause(id, /*namedBindings*/ undefined); - case 2 /* Namespace */: - return ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(id)); - case 0 /* Named */: - return ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, id)])); - default: - ts.Debug.assertNever(kind); - } - } function getNewImportInfos(program, sourceFile, moduleSymbols, host, preferences) { var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var modulePathsGroups = ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences); - return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); + return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ kind: 2 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); }); // 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, addNew) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); - var newImportInfos = existingDeclaration - ? [existingDeclaration] - : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.host, ctx.preferences); - for (var _i = 0, newImportInfos_1 = newImportInfos; _i < newImportInfos_1.length; _i++) { - var info = newImportInfos_1[_i]; - addNew.push(getCodeActionForNewImport(ctx, info)); - } + return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 244 /* ImportDeclaration */ + var expression = declaration.kind === 247 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; - return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; + return expression && ts.isStringLiteral(expression) ? { kind: 2 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; } - function tryUpdateExistingImport(context, importClause, importKind) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - var name = importClause.name; - var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 - switch (importKind) { - case 1 /* Default */: - return name ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(ts.createIdentifier(symbolName), namedBindings)); - }); - case 0 /* Named */: { - var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - 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 === 247 /* NamedImports */ && namedBindings.elements.length === 0) { - return ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); - }); - } - return undefined; - } - case 2 /* Namespace */: - return namedBindings ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamespaceImport(ts.createIdentifier(symbolName)))); - }); - case 3 /* Equals */: - return undefined; - default: - ts.Debug.assertNever(importKind); - } + function getFixesInfo(context, errorCode, pos) { + var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos); + var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getFixesInfoForUMDImport(context, symbolToken) + : getFixesInfoForNonUMDImport(context, symbolToken); + return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix, context, symbolToken) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - var changes = ChangeTracker.with(context, function (tracker) { - return tracker.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); - }); - return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); + function getFixesInfoForUMDImport(_a, token) { + var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; + var checker = program.getTypeChecker(); + var umdSymbol = getUmdSymbol(token, checker); + if (!umdSymbol) + return undefined; + var symbol = checker.getAliasedSymbol(umdSymbol); + var symbolName = umdSymbol.name; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()) }]; + var fixes = getFixForImport(exportInfos, symbolName, token, program, sourceFile, host, preferences); + return { fixes: fixes, symbolName: symbolName }; } - function getActionsForUMDImport(context) { - var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); - var checker = context.program.getTypeChecker(); - var umdSymbol; - if (ts.isIdentifier(token)) { - // try the identifier to see if it is the umd symbol - umdSymbol = checker.getSymbolAtLocation(token); - } - if (!ts.isUMDExportSymbol(umdSymbol)) { - // 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 === 260 /* JsxOpeningFragment */) { - umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); - } - } - if (ts.isUMDExportSymbol(umdSymbol)) { - var symbol = checker.getAliasedSymbol(umdSymbol); - if (symbol) { - return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(context.program.getCompilerOptions()) }], convertToImportCodeFixContext(context, token, umdSymbol.name)); - } - } - return undefined; + function getUmdSymbol(token, checker) { + // try the identifier to see if it is the umd symbol + var umdSymbol = ts.isIdentifier(token) ? checker.getSymbolAtLocation(token) : undefined; + if (ts.isUMDExportSymbol(umdSymbol)) + return umdSymbol; + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + var parent = token.parent; + return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67216319 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + : undefined; } function getUmdImportKind(compilerOptions) { // Import a synthetic `default` if enabled. @@ -103461,11 +104423,10 @@ var ts; return ts.Debug.assertNever(moduleKind); } } - function getActionsForNonUMDImport(context) { + function getFixesInfoForNonUMDImport(_a, symbolToken) { + var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. - var sourceFile = context.sourceFile, span = context.span, program = context.program, cancellationToken = context.cancellationToken; var checker = program.getTypeChecker(); - var symbolToken = ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false); // If we're at ``, we must check if `Foo` is already in scope, and if so, get an import for `React` instead. var symbolName = ts.isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken @@ -103475,14 +104436,14 @@ var ts; if (!symbolName) 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 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); + ts.Debug.assert(symbolName !== "default" /* Default */); + var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + var _ = _a[0], exportInfos = _a[1]; + return getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences); + })); + return { fixes: fixes, symbolName: symbolName }; } + // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, 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). @@ -103495,35 +104456,121 @@ var ts; // check the default export var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) { - var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); - if ((localSymbol && localSymbol.escapedName === symbolName || - getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target) === symbolName) && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { - addSymbol(moduleSymbol, localSymbol || defaultExport, 1 /* Default */); + var info = getDefaultExportInfo(defaultExport, moduleSymbol, program); + if (info && info.name === symbolName && symbolHasMeaning(info.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultExport, 1 /* Default */); } } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } - function getEscapedNameForExportDefault(symbol) { - return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { - if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.escapedText; - } - } - else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - return declaration.propertyName && declaration.propertyName.escapedText; - } - }); - } }); return originalSymbolToExportInfos; } - function checkSymbolHasMeaning(_a, meaning) { + function getDefaultExportInfo(defaultExport, moduleSymbol, program) { + var checker = program.getTypeChecker(); + var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) + return { symbolForMeaning: localSymbol, name: localSymbol.name }; + var name = getNameForExportDefault(defaultExport); + if (name !== undefined) + return { symbolForMeaning: defaultExport, name: name }; + if (defaultExport.flags & 2097152 /* Alias */) { + var aliased = checker.getAliasedSymbol(defaultExport); + return getDefaultExportInfo(aliased, ts.Debug.assertDefined(aliased.parent), program); + } + else { + var moduleName = moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target); + return moduleName === undefined ? undefined : { symbolForMeaning: defaultExport, name: moduleName }; + } + } + function getNameForExportDefault(symbol) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + if (ts.isExportAssignment(declaration)) { + if (ts.isIdentifier(declaration.expression)) { + return declaration.expression.text; + } + } + else if (ts.isExportSpecifier(declaration)) { + ts.Debug.assert(declaration.name.text === "default" /* Default */); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } + function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) { + var diag; + var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { + diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference); + }); + return codefix.createCodeFixAction("import", changes, diag, codefix.importFixId, ts.Diagnostics.Add_all_missing_imports); + } + function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) { + switch (fix.kind) { + case 0 /* UseNamespace */: + addNamespaceQualifier(changes, sourceFile, fix); + return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + doAddExistingFix(changes, sourceFile, importClause, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(importClause.parent.moduleSpecifier.getText()); + return [ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; + } + case 2 /* AddNew */: { + var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier; + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === 1 /* Default */ ? { defaultImport: symbolName, namedImports: ts.emptyArray, namespaceLikeImport: undefined } + : importKind === 0 /* Named */ ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined } + : { defaultImport: undefined, namedImports: ts.emptyArray, namespaceLikeImport: { importKind: importKind, name: symbolName } }); + return [ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; + } + default: + return ts.Debug.assertNever(fix); + } + } + function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { + if (defaultImport) { + ts.Debug.assert(!clause.name); + changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); + } + if (namedImports.length) { + var specifiers = namedImports.map(function (name) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); }); + if (clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements.length) { + for (var _i = 0, specifiers_1 = specifiers; _i < specifiers_1.length; _i++) { + var spec = specifiers_1[_i]; + changes.insertNodeInListAfter(sourceFile, ts.last(ts.cast(clause.namedBindings, ts.isNamedImports).elements), spec); + } + } + else { + if (specifiers.length) { + var namedImports_1 = ts.createNamedImports(specifiers); + if (clause.namedBindings) { + changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); + } + else { + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + } + } + } + } + } + function addNamespaceQualifier(changes, sourceFile, _a) { + var namespacePrefix = _a.namespacePrefix, symbolToken = _a.symbolToken; + changes.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); + } + function addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, _a) { + var defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport; + var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); + if (defaultImport !== undefined || namedImports.length) { + ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); + } + if (namespaceLikeImport) { + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ + ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) + : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + } + } + function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } @@ -103624,7 +104671,7 @@ var ts; // This is the identifier of the misspelled word. eg: // this.speling = 1; // ^^^^^^^ - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); // TODO: GH#15852 + var node = ts.getTokenAtPosition(sourceFile, pos); var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { @@ -103696,46 +104743,99 @@ var ts; var info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, context.preferences); + if (info.kind === InfoKind.enum) { + var token_1 = info.token, parentDeclaration_1 = info.parentDeclaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), token_1, parentDeclaration_1); }); + return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_missing_enum_member_0, token_1.text], fixId, ts.Diagnostics.Add_all_missing_members)]; + } + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); var addMember = inJs ? - ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, token.text, makeStatic)) : - getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, classDeclaration, token, makeStatic); + ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic)) : + getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, parentDeclaration, token, makeStatic); return ts.concatenate(ts.singleElementArray(methodCodeAction), addMember); }, fixIds: [fixId], getAllCodeActions: function (context) { - var seenNames = ts.createMap(); - return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var program = context.program, preferences = context.preferences; - var info = getInfo(diag.file, diag.start, program.getTypeChecker()); - if (!info) - return; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - if (!ts.addToSeen(seenNames, token.text)) { - return; - } - // Always prefer to add a method declaration if possible. - if (call) { - addMethodDeclaration(changes, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, preferences); - } - else { - if (inJs) { - addMissingMemberInJs(changes, classDeclarationSourceFile, classDeclaration, token.text, makeStatic); + var program = context.program, preferences = context.preferences; + var checker = program.getTypeChecker(); + var seen = ts.createMap(); + var classToMembers = new ts.NodeMap(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(diag.file, diag.start, checker); + if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { + return; + } + if (info.kind === InfoKind.enum) { + var token = info.token, parentDeclaration = info.parentDeclaration; + addEnumMemberDeclaration(changes, checker, token, parentDeclaration); } else { - var typeNode = getTypeNode(program.getTypeChecker(), classDeclaration, token); - addPropertyDeclaration(changes, classDeclarationSourceFile, classDeclaration, token.text, typeNode, makeStatic); + var parentDeclaration = info.parentDeclaration, token_2 = info.token; + var infos = classToMembers.getOrUpdate(parentDeclaration, function () { return []; }); + if (!infos.some(function (i) { return i.token.text === token_2.text; })) + infos.push(info); } - } - }); + }); + classToMembers.forEach(function (infos, classDeclaration) { + var superClasses = getAllSuperClasses(classDeclaration, checker); + var _loop_12 = function (info) { + // If some superclass added this property, don't add it again. + if (superClasses.some(function (superClass) { + var superInfos = classToMembers.get(superClass); + return !!superInfos && superInfos.some(function (_a) { + var token = _a.token; + return token.text === info.token.text; + }); + })) + return "continue"; + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + // Always prefer to add a method declaration if possible. + if (call) { + addMethodDeclaration(context, changes, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + } + else { + if (inJs) { + addMissingMemberInJs(changes, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic); + } + else { + var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token); + addPropertyDeclaration(changes, classDeclarationSourceFile, parentDeclaration, token.text, typeNode, makeStatic); + } + } + }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + _loop_12(info); + } + }); + })); }, }); + function getAllSuperClasses(cls, checker) { + var res = []; + while (cls) { + var superElement = ts.getClassExtendsHeritageElement(cls); + var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); + var superDecl = superSymbol && ts.find(superSymbol.declarations, ts.isClassLike); + if (superDecl) { + res.push(superDecl); + } + cls = superDecl; + } + return res; + } + var InfoKind; + (function (InfoKind) { + InfoKind[InfoKind["enum"] = 0] = "enum"; + InfoKind[InfoKind["class"] = 1] = "class"; + })(InfoKind || (InfoKind = {})); function getInfo(tokenSourceFile, tokenPos, checker) { // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ - var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos); if (!ts.isIdentifier(token)) { return undefined; } @@ -103744,14 +104844,21 @@ var ts; return undefined; var leftExpressionType = ts.skipConstraint(checker.getTypeAtLocation(parent.expression)); var symbol = leftExpressionType.symbol; - var classDeclaration = symbol && symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); - if (!classDeclaration) + if (!symbol || !symbol.declarations) return undefined; - var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); - var classDeclarationSourceFile = classDeclaration.getSourceFile(); - var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); - var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { token: token, classDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); + if (classDeclaration) { + var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); + var classDeclarationSourceFile = classDeclaration.getSourceFile(); + var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); + var call = ts.tryCast(parent.parent, ts.isCallExpression); + return { kind: InfoKind.class, token: token, parentDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + } + var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); + if (enumDeclaration) { + return { kind: InfoKind.enum, token: token, parentDeclaration: enumDeclaration }; + } + return undefined; } function getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic); }); @@ -103760,7 +104867,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 205 /* ClassExpression */) { + if (classDeclaration.kind === 207 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -103786,7 +104893,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 200 /* BinaryExpression */) { + if (token.parent.parent.kind === 202 /* 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))); // TODO: GH#18217 @@ -103840,11 +104947,11 @@ var ts; return codefix.createCodeFixActionNoFixId(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]); } function getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, token.text], fixId, ts.Diagnostics.Add_all_missing_members); } - function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); + function addMethodDeclaration(context, changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { + var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences); var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); @@ -103853,6 +104960,19 @@ var ts; changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); } } + function addEnumMemberDeclaration(changes, checker, token, enumDeclaration) { + /** + * create initializer only literal enum that has string initializer. + * value of initializer is a string literal that equal to name of enum member. + * numeric enum or empty enum will not create initializer. + */ + var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { + var type = checker.getTypeAtLocation(member); + return !!(type && type.flags & 68 /* StringLike */); + }); + var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); + changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -103886,7 +105006,7 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function getTypesPackageNameToInstall(host, sourceFile, pos, diagCode) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), ts.isStringLiteral).text; + var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) @@ -103927,11 +105047,11 @@ var ts; function getClass(sourceFile, pos) { // Token is the identifier in the case of a class declaration // or the class keyword token in the case of a class expression. - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.cast(token.parent, ts.isClassLike); } function addMissingMembers(classDeclaration, sourceFile, checker, changeTracker, preferences) { - var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var extendsNode = ts.getEffectiveBaseTypeNode(classDeclaration); var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. @@ -103981,10 +105101,10 @@ var ts; }); function doChange(changes, sourceFile, constructor, superCall) { changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall); - changes.deleteNode(sourceFile, superCall); + changes.delete(sourceFile, superCall); } function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); if (token.kind !== 99 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); @@ -104023,7 +105143,7 @@ var ts; }); }, }); function getNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); return token.parent; } @@ -104059,7 +105179,7 @@ var ts; }); }, }); function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; @@ -104115,7 +105235,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos, diagCode) { - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(node)) return undefined; return { node: node, className: diagCode === didYouMeanStaticMemberCode ? ts.getContainingClass(node).name.text : undefined }; @@ -104149,25 +105269,30 @@ var ts; getCodeActions: function (context) { 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); + var sourceFiles = program.getSourceFiles(); + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var importDecl = tryGetFullImport(token); if (importDecl) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(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, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteFullDestructure(token, t, sourceFile, checker, sourceFiles, /*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); }); + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(sourceFile, token, t); }); 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, checker, /*isFixAll*/ false); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteDeclaration(sourceFile, token, t, checker, sourceFiles, /*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)); + var name = ts.isComputedPropertyName(token.parent) ? token.parent : token; + result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, name.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } var prefix = ts.textChanges.ChangeTracker.with(context, function (t) { return tryPrefixDeclaration(t, errorCode, sourceFile, token); }); if (prefix.length) { @@ -104177,32 +105302,28 @@ 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 ts.NodeSet(); var sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); + var sourceFiles = program.getSourceFiles(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); - var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); + var token = ts.getTokenAtPosition(sourceFile, diag.start); switch (context.fixId) { case fixIdPrefix: if (ts.isIdentifier(token) && canPrefix(token)) { tryPrefixDeclaration(changes, diag.code, sourceFile, token); } break; - case fixIdDelete: - // Ignore if this range was already deleted. - if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) - break; - var importDecl = tryGetFullImport(startToken); + case fixIdDelete: { + var importDecl = tryGetFullImport(token); if (importDecl) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } - else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && - !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); + else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(sourceFile, token, changes)) { + tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, /*isFixAll*/ true); } break; + } default: ts.Debug.fail(JSON.stringify(context.fixId)); } @@ -104210,49 +105331,29 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(startToken) { - return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; + function tryGetFullImport(token) { + return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { - if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) + function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { + if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; - var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; - switch (decl.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(decl, checker, isFixAll)) - break; - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNodeInList(sourceFile, decl); - break; - case 182 /* BindingElement */: - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNode(sourceFile, decl); - break; - default: - return ts.Debug.assertNever(decl); + var decl = token.parent.parent; + if (decl.kind === 149 /* Parameter */) { + tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); + } + else { + changes.delete(sourceFile, decl); } 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); + function tryDeleteFullVariableStatement(sourceFile, token, changes) { + var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { + changes.delete(sourceFile, declarationList.parent.kind === 217 /* 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; - return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token; - } function tryPrefixDeclaration(changes, errorCode, sourceFile, token) { // Don't offer to prefix a property. if (errorCode !== ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code && ts.isIdentifier(token) && canPrefix(token)) { @@ -104263,209 +105364,61 @@ var ts; switch (token.parent.kind) { case 149 /* Parameter */: return true; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { - tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll); + function tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, isFixAll) { + tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll); if (ts.isIdentifier(token)) deleteAssignments(changes, sourceFile, token, checker); } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 185 /* PropertyAccessExpression */) + if (ref.parent.kind === 187 /* PropertyAccessExpression */) ref = ref.parent; - if (ref.parent.kind === 200 /* BinaryExpression */ && ref.parent.parent.kind === 216 /* ExpressionStatement */) { - changes.deleteNode(sourceFile, ref.parent.parent); + if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + changes.delete(sourceFile, ref.parent.parent); } }); } - function tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { + function tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll) { var parent = token.parent; - switch (parent.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); - break; - 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; - var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false); - var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false); - ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); - ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); - changes.deleteNodeRange(sourceFile, previousToken, nextToken); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - 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, // 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. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 182 /* BindingElement */: { - var pattern = parent.parent; - var preserveComma = pattern.kind === 181 /* ArrayBindingPattern */ && parent !== ts.last(pattern.elements); - if (preserveComma) { - changes.deleteNode(sourceFile, parent); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - } - // handle case where 'import a = A;' - case 243 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(token, 243 /* ImportEqualsDeclaration */); - changes.deleteNode(sourceFile, importEquals); - break; - case 248 /* ImportSpecifier */: - var namedImports = parent.parent; - if (namedImports.elements.length === 1) { - tryDeleteNamedImportBinding(changes, sourceFile, namedImports); - } - else { - // delete import specifier - changes.deleteNodeInList(sourceFile, parent); - } - break; - 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, 244 /* ImportDeclaration */)); - } - else { - // import |d,| * as ns from './file' - var start = importClause.name.getStart(sourceFile); - var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end, /*includeJsDocComment*/ false); - if (nextToken && nextToken.kind === 26 /* CommaToken */) { - // shift first non-whitespace position after comma to the start position of the node - var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); - changes.deleteRange(sourceFile, { pos: start, end: end }); - } - else { - changes.deleteNode(sourceFile, importClause.name); - } - } - break; - case 246 /* NamespaceImport */: - tryDeleteNamedImportBinding(changes, sourceFile, parent); - break; - default: - if (ts.isDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent); - changes.deleteNode(sourceFile, token.parent); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent.parent); - changes.deleteNode(sourceFile, token.parent.parent); - } - break; - } - } - function tryDeleteNamedImportBinding(changes, sourceFile, namedBindings) { - if (namedBindings.parent.name) { - // Delete named imports while preserving the default import - // import d|, * as ns| from './file' - // import d|, { a }| from './file' - var previousToken = ts.getTokenAtPosition(sourceFile, namedBindings.pos - 1, /*includeJsDocComment*/ false); - if (previousToken && previousToken.kind === 26 /* CommaToken */) { - changes.deleteRange(sourceFile, { pos: previousToken.getStart(), end: namedBindings.end }); - } + if (ts.isParameter(parent)) { + tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, isFixAll); } else { - // Delete the entire import declaration - // |import * as ns from './file'| - // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); } } - // token.parent is a variableDeclaration - function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { - switch (varDecl.parent.parent.kind) { - case 220 /* ForStatement */: { - var forStatement = varDecl.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(forInitializer); - changes.deleteNode(sourceFile, forInitializer); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } - break; - } - case 222 /* ForOfStatement */: - var forOfStatement = varDecl.parent.parent; - 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 221 /* ForInStatement */: - case 230 /* TryStatement */: - break; - default: - var variableStatement = varDecl.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(variableStatement); - changes.deleteNode(sourceFile, variableStatement); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } + function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { + if (mayDeleteParameter(p, checker, isFixAll)) { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { case 154 /* MethodDeclaration */: - // Don't remove a parameter if this overrides something + // 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. + case 237 /* FunctionDeclaration */: + return true; + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: { + // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); @@ -104480,6 +105433,14 @@ var ts; return ts.Debug.failBadSyntaxKind(parent); } } + function deleteUnusedArguments(changes, sourceFile, deletedParameter, sourceFiles, checker) { + ts.FindAllReferences.Core.eachSignatureCall(deletedParameter.parent, sourceFiles, checker, function (call) { + var index = deletedParameter.parent.parameters.indexOf(deletedParameter); + if (call.arguments.length > index) { // Just in case the call didn't provide enough arguments. + changes.delete(sourceFile, call.arguments[index]); + } + }); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104499,12 +105460,12 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -104515,16 +105476,16 @@ var ts; break; } // falls through - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - changes.deleteNode(sourceFile, container); + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + changes.delete(sourceFile, container); break; default: if (ts.isBlock(statement.parent)) { split(sliceAfter(statement.parent.statements, statement), shouldRemove, function (start, end) { return changes.deleteNodeRange(sourceFile, start, end); }); } else { - changes.deleteNode(sourceFile, statement); + changes.delete(sourceFile, statement); } } } @@ -104536,12 +105497,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -104575,7 +105536,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var labeledStatement = ts.cast(token.parent, ts.isLabeledStatement); var pos = token.getStart(sourceFile); var statementPos = labeledStatement.statement.getStart(sourceFile); @@ -104605,7 +105566,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 281 /* JSDocNullableType */) { + if (typeNode.kind === 284 /* 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, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -104625,7 +105586,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -104634,7 +105595,7 @@ var ts; 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); + var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), isTypeContainer); var typeNode = decl && decl.type; return typeNode && { typeNode: typeNode, type: checker.getTypeFromTypeNode(typeNode) }; } @@ -104642,22 +105603,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 208 /* AsExpression */: + case 210 /* AsExpression */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 156 /* GetAccessor */: case 160 /* IndexSignature */: - case 177 /* MappedType */: + case 179 /* 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 */: + case 240 /* TypeAliasDeclaration */: + case 192 /* TypeAssertionExpression */: + case 235 /* VariableDeclaration */: return true; default: return false; @@ -104704,7 +105665,7 @@ var ts; } } function getNodes(sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var containingFunction = ts.getContainingFunction(token); if (!containingFunction) { return; @@ -104714,11 +105675,11 @@ var ts; case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -104888,8 +105849,22 @@ var ts; signatureDeclaration.body = body; return signatureDeclaration; } - function createMethodFromCallExpression(_a, methodName, inJs, makeStatic, preferences) { + function createMethodFromCallExpression(context, _a, methodName, inJs, makeStatic, preferences) { var typeArguments = _a.typeArguments, args = _a.arguments, parent = _a.parent; + var checker = context.program.getTypeChecker(); + var types = ts.map(args, function (arg) { + var type = checker.getTypeAtLocation(arg); + if (type === undefined) { + return undefined; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + type = checker.getBaseTypeOfLiteralType(type); + return checker.typeToTypeNode(type); + }); + var names = ts.map(args, function (arg) { + return ts.isIdentifier(arg) ? arg.text : + ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + }); return ts.createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, @@ -104898,11 +105873,11 @@ var ts; /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); }), - /*parameters*/ createDummyParameters(args.length, /*names*/ undefined, /*minArgumentCount*/ undefined, inJs), + /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), createStubbedMethodBody(preferences)); } codefix.createMethodFromCallExpression = createMethodFromCallExpression; - function createDummyParameters(argCount, names, minArgumentCount, inJs) { + function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; for (var i = 0; i < argCount; i++) { var newParameter = ts.createParameter( @@ -104911,7 +105886,7 @@ var ts; /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -104937,7 +105912,7 @@ var ts; } var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); - var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*inJs*/ false); + var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); var restParameter = ts.createParameter( @@ -105001,18 +105976,19 @@ var ts; if (ts.isSourceFileJavaScript(sourceFile)) { return undefined; // TODO: GH#20113 } - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var declaration; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeenseen*/ ts.returnTrue); }); - return changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getNameOfDeclaration(declaration).getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start, /*includeJsDocComment*/ false), err.code, program, cancellationToken, markSeen); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen); }); }, }); @@ -105094,11 +106070,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return !!declaration.name; } return false; @@ -105158,8 +106134,8 @@ var ts; function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? @@ -105227,21 +106203,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -105249,13 +106225,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 232 /* VariableDeclaration */: { + case 235 /* 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. @@ -105364,7 +106340,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -105392,7 +106368,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 187 /* CallExpression */) { + if (parent.kind === 189 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -105560,8 +106536,8 @@ 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 ? 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); }); + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -105588,7 +106564,7 @@ var ts; }); function getActionsForInvalidImportLocation(context) { var sourceFile = context.sourceFile; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -105663,7 +106639,7 @@ var ts; }, }); function getPropertyDeclaration(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined; } function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) { @@ -105748,7 +106724,7 @@ var ts; : ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, name, ts.createExternalModuleReference(required))); } function getInfo(sourceFile, pos) { - var parent = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false).parent; + var parent = ts.getTokenAtPosition(sourceFile, pos).parent; if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ true)) throw ts.Debug.failBadSyntaxKind(parent); var decl = ts.cast(parent.parent, ts.isVariableDeclaration); @@ -105781,7 +106757,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos) { - var name = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(name)) return undefined; // bad input var parent = name.parent; @@ -105805,7 +106781,7 @@ var ts; (function (codefix) { var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof"; var fixId = fixIdAddMissingTypeof; - var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code]; + var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { @@ -105820,9 +106796,9 @@ var ts; }); }, }); function getImportTypeNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 179 /* ImportType */); + ts.Debug.assert(token.parent.kind === 181 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -105858,7 +106834,7 @@ var ts; }); } }); function getInfo(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); if (ts.isClassDeclaration(indexSignature.parent)) return undefined; @@ -105887,129 +106863,325 @@ 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) + var refactorName = "Convert export"; + var actionNameDefaultToNamed = "Convert default export to named export"; + var actionNameNamedToDefault = "Convert named export to default export"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var info = getInfo(context); + if (!info) + return undefined; + var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; + var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + }, + }); + function getInfo(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var exportNode = ts.getParentNodeInSpan(token, file, span); + if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { + return undefined; + } + var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; + var flags = ts.getModifierFlags(exportNode); + var wasDefault = !!(flags & 512 /* Default */); + // If source file already has a default export, don't offer refactor. + if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + return undefined; + } + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: { + var node = exportNode; + return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + case 217 /* VariableStatement */: { + var vs = exportNode; + // Must be `export const x = something;`. + if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { 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 }; + } + var decl = ts.first(vs.declarationList.declarations); + if (!decl.initializer) + return undefined; + ts.Debug.assert(!wasDefault); + return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + default: + return undefined; + } + } + function doChange(exportingSourceFile, program, info, changes, cancellationToken) { + changeExport(exportingSourceFile, info, changes, program.getTypeChecker()); + changeImports(program, info, changes, cancellationToken); + } + function changeExport(exportingSourceFile, _a, changes, checker) { + var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; + if (wasDefault) { + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + } + else { + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + break; + case 217 /* VariableStatement */: + // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` + if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { + // We checked in `getInfo` that an initializer exists. + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + break; + } + // falls through + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: + // `export type T = number;` -> `type T = number; export default T;` + changes.deleteModifier(exportingSourceFile, exportKeyword); + changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); + break; + default: + ts.Debug.assertNever(exportNode); + } + } + } + function changeImports(program, _a, changes, cancellationToken) { + var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; + var checker = program.getTypeChecker(); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { + var importingSourceFile = ref.getSourceFile(); + if (wasDefault) { + changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text); + } + else { + changeNamedToDefaultImport(importingSourceFile, ref, changes); } }); - // 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())); + } + function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.default` --> `a.foo` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + // `default as foo` --> `foo`, `default as bar` --> `foo as bar` + changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); + break; } - 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; + case 248 /* ImportClause */: { + var clause = parent; + ts.Debug.assert(clause.name === ref); + var spec = makeImportSpecifier(exportName, ref.text); + var namedBindings = clause.namedBindings; + if (!namedBindings) { + // `import foo from "./a";` --> `import { foo } from "./a";` + changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); + } + else if (namedBindings.kind === 249 /* NamespaceImport */) { + // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` + changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); + changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } 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); + // `import foo, { bar } from "./a"` --> `import { bar, foo } from "./a";` + changes.delete(importingSourceFile, ref); + changes.insertNodeAtEndOfList(importingSourceFile, namedBindings.elements, spec); } - }); - // 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)); + break; } + default: + ts.Debug.failBadSyntaxKind(parent); } - 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_11 = 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))); - } + } + function changeNamedToDefaultImport(importingSourceFile, ref, changes) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.foo` --> `a.default` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + if (spec.kind === 251 /* ImportSpecifier */) { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(spec.name.text); + if (spec.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, spec.parent, defaultImport); } else { - changes.replaceNode(sourceFile, id, access); + changes.delete(importingSourceFile, spec); + changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); } - }); - }; - for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { - var element = _a[_i]; - _loop_11(element); + } + else { + // `export { foo } from "./a";` --> `export { default as foo } from "./a";` + // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` + // `export { foo as default } from "./a";` --> `export { default } from "./a";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + } + break; } - changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); - if (neededNamedImports.length) { - changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + default: + ts.Debug.failBadSyntaxKind(parent); + } + } + function makeImportSpecifier(propertyName, name) { + return ts.createImportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + function makeExportSpecifier(propertyName, name) { + return ts.createExportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + 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 === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 249 /* 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); + 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 === 249 /* 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)); } - function updateImport(old, defaultImportName, elements) { - return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + 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)); } - })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + 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_13 = 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_13(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); + } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); /* @internal */ @@ -106167,7 +107339,7 @@ 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 = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start), sourceFile, span); // Do the same for the ending position var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; @@ -106320,7 +107492,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 235 /* 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`! @@ -106332,13 +107504,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* 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 === 187 /* CallExpression */) { + if (node.parent.kind === 189 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -106353,8 +107525,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -106366,20 +107538,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 213 /* Block */: - if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { + case 216 /* Block */: + if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -106391,11 +107563,11 @@ var ts; break; } switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -106403,8 +107575,8 @@ var ts; seenLabels.pop(); break; } - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: { var label = node.label; if (label) { @@ -106414,20 +107586,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -106492,7 +107664,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 274 /* SourceFile */) { + if (current.kind === 277 /* SourceFile */) { return scopes; } } @@ -106584,12 +107756,12 @@ var ts; switch (scope.kind) { case 155 /* Constructor */: return "constructor"; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return "arrow function"; case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); @@ -106602,12 +107774,12 @@ var ts; } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 235 /* ClassDeclaration */ + return scope.kind === 238 /* 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 === 240 /* ModuleBlock */ + return scope.kind === 243 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -106886,7 +108058,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 216 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 219 /* 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( @@ -106905,9 +108077,9 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 216 /* ExpressionStatement */) { + if (node.parent.kind === 219 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. - changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); + changeTracker.delete(context.file, node.parent); } else { var localReference = ts.createIdentifier(localNameText); @@ -106992,7 +108164,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -107170,7 +108342,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 !== 234 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -107233,7 +108405,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_12 = function (i) { + var _loop_14 = 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 @@ -107273,7 +108445,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_12(i); + _loop_14(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -107486,30 +108658,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 273 /* EnumMember */: + case 276 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return parent.kind !== 244 /* ImportDeclaration */ && - parent.kind !== 248 /* ImportSpecifier */; - case 204 /* SpreadElement */: - case 180 /* ObjectBindingPattern */: - case 182 /* BindingElement */: + return parent.kind !== 247 /* ImportDeclaration */ && + parent.kind !== 251 /* ImportSpecifier */; + case 206 /* SpreadElement */: + case 182 /* ObjectBindingPattern */: + case 184 /* BindingElement */: return false; case 71 /* Identifier */: - return parent.kind !== 182 /* BindingElement */ && - parent.kind !== 248 /* ImportSpecifier */ && - parent.kind !== 252 /* ExportSpecifier */; + return parent.kind !== 184 /* BindingElement */ && + parent.kind !== 251 /* ImportSpecifier */ && + parent.kind !== 255 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 213 /* Block */: - case 274 /* SourceFile */: - case 240 /* ModuleBlock */: - case 266 /* CaseClause */: + case 216 /* Block */: + case 277 /* SourceFile */: + case 243 /* ModuleBlock */: + case 269 /* CaseClause */: return true; default: return false; @@ -107529,8 +108701,7 @@ var ts; var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { - var file = context.file; - if (!getConvertibleFieldAtPosition(context, file)) + if (!getConvertibleFieldAtPosition(context)) return undefined; return [{ name: actionName, @@ -107545,7 +108716,7 @@ var ts; } function getEditsForAction(context, _actionName) { var file = context.file; - var fieldInfo = getConvertibleFieldAtPosition(context, file); + var fieldInfo = getConvertibleFieldAtPosition(context); if (!fieldInfo) return undefined; var isJS = ts.isSourceFileJavaScript(file); @@ -107606,13 +108777,13 @@ var ts; function startsWithUnderscore(name) { return name.charCodeAt(0) === 95 /* _ */; } - function getConvertibleFieldAtPosition(context, file) { - var startPosition = context.startPosition, endPosition = context.endPosition; - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + function getConvertibleFieldAtPosition(context) { + var file = context.file, startPosition = context.startPosition, endPosition = context.endPosition; + var node = ts.getTokenAtPosition(file, startPosition); 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) // TODO: GH#18217 + if (!declaration || !ts.nodeOverlapsWithStartEnd(declaration.name, file, startPosition, endPosition) // TODO: GH#18217 || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; @@ -107767,11 +108938,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return true; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -107824,10 +108995,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_13 = function (sourceFile) { + var _loop_15 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_14 = function (statement) { + var _loop_16 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -107849,22 +109020,22 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_14(statement); + _loop_16(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_13(sourceFile); + _loop_15(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + case 247 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -107895,20 +109066,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -107978,15 +109149,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -107999,23 +109170,23 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } else { if (name && defaultUnused) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } if (namedBindings) { if (namedBindingsUnused) { - changes.deleteNode(sourceFile, namedBindings); + changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 247 /* NamedImports */) { + else if (namedBindings.kind === 250 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) - changes.deleteNodeInList(sourceFile, element); + changes.delete(sourceFile, element); } } } @@ -108026,20 +109197,20 @@ var ts; switch (name.kind) { case 71 /* Identifier */: if (isUnused(name)) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: break; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); + changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } else { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (ts.isIdentifier(element.name) && isUnused(element.name)) { - changes.deleteNode(sourceFile, element.name); + changes.delete(sourceFile, element.name); } } } @@ -108136,13 +109307,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: return true; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -108154,7 +109325,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -108164,9 +109335,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -108175,7 +109346,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -108187,9 +109358,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return name; - case 180 /* ObjectBindingPattern */: { + case 182 /* 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; @@ -108246,13 +109417,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -108260,17 +109431,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return cb(statement); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -108279,7 +109450,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -108311,23 +109482,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -108338,18 +109509,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -108424,7 +109595,7 @@ var ts; return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(file, startPosition); var func = ts.getContainingFunction(node); if (!func || !ts.isArrowFunction(func) || (!ts.rangeContainsRange(func, node) || ts.rangeContainsRange(func.body, node))) return undefined; @@ -108530,7 +109701,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 299 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 302 /* LastJSDocNode */; }); return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -108600,7 +109771,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(300 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(303 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -108657,7 +109828,7 @@ var ts; return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { - return ts.emptyArray; + return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -108911,7 +110082,7 @@ var ts; }; SourceFileObject.prototype.computeNamedDeclarations = function () { var result = ts.createMultiMap(); - ts.forEachChild(this, visit); + this.forEachChild(visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); @@ -108927,14 +110098,14 @@ var ts; return declarations; } function getDeclarationName(declaration) { - var name = ts.getNameOfDeclaration(declaration); + var name = ts.getNonAssignedNameOfDeclaration(declaration); return name && (ts.isComputedPropertyName(name) && ts.isPropertyAccessExpression(name.expression) ? name.expression.name.text : ts.isPropertyName(name) ? ts.getNameFromPropertyName(name) : undefined); } function visit(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: var functionDeclaration = node; @@ -108956,17 +110127,17 @@ var ts; } ts.forEachChild(node, visit); break; - 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 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 166 /* TypeLiteral */: @@ -108979,8 +110150,8 @@ var ts; break; } // falls through - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: { + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -108991,31 +110162,31 @@ var ts; } } // falls through - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: addDeclaration(node); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addDeclaration(importClause); + addDeclaration(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -109024,7 +110195,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -109392,7 +110563,7 @@ var ts; readFile: function (fileName) { // stub missing host functionality var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); if (entry) { return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot); } @@ -109442,7 +110613,7 @@ var ts; return; function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : (!!host.fileExists && host.fileExists(fileName)); @@ -109457,11 +110628,11 @@ var ts; return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); } function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { - ts.Debug.assert(hostCache !== undefined); + ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined // to the program to allow reporting of errors for missing files. - var hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path); + var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path); if (!hostFileInformation) { return undefined; } @@ -109557,17 +110728,17 @@ var ts; return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { - if (options === void 0) { options = ts.defaultPreferences; } + if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 - getCanonicalFileName, preferences, cancellationToken); + preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -109592,10 +110763,10 @@ var ts; return undefined; } // falls through - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_1 = typeChecker.getTypeAtLocation(node); @@ -109640,7 +110811,8 @@ var ts; 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]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; function scanForSourcemapURL(fileName) { var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); @@ -109649,11 +110821,15 @@ var ts; } var starts = ts.getLineStarts(mappedFile); for (var index = starts.length - 1; index >= 0; index--) { - sourceMapCommentRegExp.lastIndex = starts[index]; - var comment = sourceMapCommentRegExp.exec(mappedFile.text); + var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); + var comment = sourceMapCommentRegExp.exec(lineText); if (comment) { return comment[1]; } + // If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!lineText.match(whitespaceOrMapCommentRegExp)) { + break; + } } } function convertDocumentToSourceMapper(file, contents, mapFileName) { @@ -109807,18 +110983,32 @@ var ts; return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; + return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); }); + } + else { + var refs = getReferences(node, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + return refs && refs.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + return ({ fileName: fileName, textSpan: textSpan }); + }); + } } function getReferencesAtPosition(fileName, position) { - return getReferences(fileName, position); + synchronizeHostData(); + return getReferences(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position); } - function getReferences(fileName, position, options) { + function getReferences(node, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. 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); + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -109842,10 +111032,11 @@ var ts; /** * This is a semantic operation. */ - function getSignatureHelpItems(fileName, position) { + function getSignatureHelpItems(fileName, position, _a) { + var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); } /// Syntactic features function getNonBoundSourceFile(fileName) { @@ -109859,7 +111050,7 @@ var ts; return undefined; } switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: @@ -109867,7 +111058,7 @@ var ts; case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span @@ -109884,7 +111075,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 === 239 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 242 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -109954,7 +111145,7 @@ var ts; braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var token = ts.getTouchingToken(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, position); var matchKind = token.getStart(sourceFile) === position ? braceMatching.get(token.kind.toString()) : undefined; var match = matchKind && ts.findChildOfKind(token.parent, matchKind, sourceFile); // We want to order the braces when we return the result. @@ -109995,7 +111186,7 @@ var ts; return []; } function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = ts.createTextSpanFromBounds(start, end); @@ -110006,7 +111197,7 @@ var ts; }); } function getCombinedCodeFix(scope, fixId, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110014,7 +111205,7 @@ var ts; return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } function organizeImports(scope, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110022,7 +111213,7 @@ var ts; return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { @@ -110085,8 +111276,8 @@ var ts; } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); - return range && ts.createTextSpanFromRange(range); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); + return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -110214,8 +111405,7 @@ var ts; } function getRenameInfo(fileName, position) { synchronizeHostData(); - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - return ts.Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); + return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position); } function getRefactorContext(file, positionOrRange, preferences, formatOptions) { var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1]; @@ -110231,13 +111421,13 @@ var ts; }; } function getApplicableRefactors(fileName, positionOrRange, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getApplicableRefactors(getRefactorContext(file, positionOrRange, preferences)); } function getEditsForRefactor(fileName, formatOptions, positionOrRange, refactorName, actionName, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); @@ -110331,7 +111521,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 254 /* ExternalModuleReference */ || + node.parent.kind === 257 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -110349,7 +111539,7 @@ var ts; // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && + (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -110388,7 +111578,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 186 /* ElementAccessExpression */ && + node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -110419,7 +111609,7 @@ var ts; if (sourceFile.isDeclarationFile) { return undefined; } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { // Get previous token if the token is returned starts on new line @@ -110468,114 +111658,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return spanInVariableDeclaration(node); case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanInBlock(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInBlock(node.block); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 217 /* IfStatement */: + case 220 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return spanInForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 182 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 184 /* BindingElement */: // span on complete node return textSpan(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: // span in statement return spanInNode(node.statement); case 150 /* Decorator */: return spanInNodeArray(parent.decorators); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -110618,13 +111808,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 === 204 /* SpreadElement */ || - node.kind === 270 /* PropertyAssignment */ || - node.kind === 271 /* ShorthandPropertyAssignment */) && + node.kind === 206 /* SpreadElement */ || + node.kind === 273 /* PropertyAssignment */ || + node.kind === 274 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 200 /* BinaryExpression */) { + if (node.kind === 202 /* 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 @@ -110646,22 +111836,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: return textSpan(node); - case 200 /* BinaryExpression */: + case 202 /* 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 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -110670,20 +111860,20 @@ var ts; } } switch (node.parent.kind) { - case 270 /* PropertyAssignment */: + case 273 /* 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 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; @@ -110692,7 +111882,7 @@ var ts; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -110722,7 +111912,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -110734,7 +111924,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 222 /* ForOfStatement */) { + parent.parent.kind === 225 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -110775,7 +111965,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -110798,26 +111988,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 221 /* ForInStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 224 /* 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 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 236 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -110842,21 +112032,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 182 /* BindingElement */) { + if (bindingPattern.parent.kind === 184 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - 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; }); + ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); + var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -110864,18 +112054,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 === 200 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 202 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -110883,25 +112073,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 240 /* ModuleBlock */: + case 243 /* 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 238 /* EnumDeclaration */: - case 235 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -110909,7 +112099,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); @@ -110925,7 +112115,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 181 /* ArrayBindingPattern */: + case 183 /* 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); @@ -110940,12 +112130,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 187 /* CallExpression */ || - node.parent.kind === 188 /* NewExpression */) { + if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 189 /* CallExpression */ || + node.parent.kind === 190 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 191 /* ParenthesizedExpression */) { + if (node.parent.kind === 193 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -110954,21 +112144,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* 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 */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 193 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -110978,20 +112168,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 273 /* PropertyAssignment */ || node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 190 /* TypeAssertionExpression */) { + if (node.parent.kind === 192 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 218 /* DoStatement */) { + if (node.parent.kind === 221 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -110999,7 +112189,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.kind === 225 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -111419,9 +112609,9 @@ var ts; return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -112219,18 +113409,24 @@ var ts; })(ts || (ts = {})); //# sourceMappingURL=jsTyping.js.map "use strict"; -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); }; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -112465,6 +113661,7 @@ var ts; CommandTypes["Change"] = "change"; CommandTypes["Close"] = "close"; CommandTypes["Completions"] = "completions"; + CommandTypes["CompletionInfo"] = "completionInfo"; CommandTypes["CompletionsFull"] = "completions-full"; CommandTypes["CompletionDetails"] = "completionEntryDetails"; CommandTypes["CompletionDetailsFull"] = "completionEntryDetails-full"; @@ -112596,16 +113793,15 @@ var ts; var server; (function (server) { var TextStorage = (function () { - function TextStorage(host, fileName) { + function TextStorage(host, fileName, initialVersion) { this.host = host; this.fileName = fileName; - this.svcVersion = 0; - this.textVersion = 0; + this.version = initialVersion || { svc: 0, text: 0 }; } TextStorage.prototype.getVersion = function () { return this.svc - ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshotVersion() - : "Text-" + this.textVersion; + ? "SVC-" + this.version.svc + "-" + this.svc.getSnapshotVersion() + : "Text-" + this.version.text; }; TextStorage.prototype.hasScriptVersionCache_TestOnly = function () { return this.svc !== undefined; @@ -112617,7 +113813,7 @@ var ts; this.svc = undefined; this.text = newText; this.lineMap = undefined; - this.textVersion++; + this.version.text++; }; TextStorage.prototype.edit = function (start, end, newText) { this.switchToScriptVersionCache().edit(start, end - start, newText); @@ -112684,7 +113880,7 @@ var ts; TextStorage.prototype.switchToScriptVersionCache = function () { if (!this.svc || this.pendingReloadFromDisk) { this.svc = server.ScriptVersionCache.fromString(this.getOrLoadText()); - this.svcVersion++; + this.version.svc++; } return this.svc; }; @@ -112716,7 +113912,7 @@ var ts; } server.isDynamicFileName = isDynamicFileName; var ScriptInfo = (function () { - function ScriptInfo(host, fileName, scriptKind, hasMixedContent, path) { + function ScriptInfo(host, fileName, scriptKind, hasMixedContent, path, initialVersion) { this.host = host; this.fileName = fileName; this.scriptKind = scriptKind; @@ -112724,7 +113920,7 @@ var ts; this.path = path; this.containingProjects = []; this.isDynamic = isDynamicFileName(fileName); - this.textStorage = new TextStorage(host, fileName); + this.textStorage = new TextStorage(host, fileName, initialVersion); if (hasMixedContent || this.isDynamic) { this.textStorage.reload(""); this.realpath = this.path; @@ -112733,6 +113929,9 @@ var ts; ? scriptKind : ts.getScriptKindFromFileName(fileName); } + ScriptInfo.prototype.getVersion = function () { + return this.textStorage.version; + }; ScriptInfo.prototype.isDynamicOrHasMixedContent = function () { return this.hasMixedContent || this.isDynamic; }; @@ -112880,7 +114079,7 @@ var ts; } if (preferences) { if (!this.preferences) { - this.preferences = ts.defaultPreferences; + this.preferences = ts.emptyOptions; } this.preferences = __assign({}, this.preferences, preferences); } @@ -114275,6 +115474,7 @@ var ts; function ProjectService(opts) { var _this = this; this.filenameToScriptInfo = ts.createMap(); + this.filenameToScriptInfoVersion = ts.createMap(); this.allJsFilesForOpenFileTelemetry = ts.createMap(); this.externalProjectToConfiguredProjectMap = ts.createMap(); this.externalProjects = []; @@ -114323,7 +115523,7 @@ var ts; this.typingsCache = new server.TypingsCache(this.typingsInstaller); this.hostConfiguration = { formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), - preferences: ts.defaultPreferences, + preferences: ts.emptyOptions, hostInfo: "Unknown host", extraFileExtensions: [] }; @@ -114494,18 +115694,29 @@ var ts; } return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); }; - ProjectService.prototype.getDefaultProjectForFile = function (fileName, ensureProject) { - var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - if (ensureProject && (!scriptInfo || scriptInfo.isOrphan())) { - this.ensureProjectStructuresUptoDate(); - scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - if (!scriptInfo) { - return server.Errors.ThrowNoProject(); - } - return scriptInfo.getDefaultProject(); + ProjectService.prototype.forEachProject = function (cb) { + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var p = _a[_i]; + cb(p); } + this.configuredProjects.forEach(cb); + this.externalProjects.forEach(cb); + }; + ProjectService.prototype.getDefaultProjectForFile = function (fileName, ensureProject) { + return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName); + }; + ProjectService.prototype.tryGetDefaultProjectForFile = function (fileName) { + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined; }; + ProjectService.prototype.ensureDefaultProjectForFile = function (fileName) { + return this.tryGetDefaultProjectForFile(fileName) || this.doEnsureDefaultProjectForFile(fileName); + }; + ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) { + this.ensureProjectStructuresUptoDate(); + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); + return scriptInfo ? scriptInfo.getDefaultProject() : server.Errors.ThrowNoProject(); + }; ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) { this.ensureProjectStructuresUptoDate(); return this.getScriptInfo(uncheckedFileName); @@ -114531,6 +115742,12 @@ var ts; var info = this.getScriptInfoForNormalizedPath(file); return info && info.getPreferences() || this.hostConfiguration.preferences; }; + ProjectService.prototype.getHostFormatCodeOptions = function () { + return this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.getHostPreferences = function () { + return this.hostConfiguration.preferences; + }; ProjectService.prototype.onSourceFileChanged = function (fileName, eventKind, path) { var info = this.getScriptInfoForPath(path); if (!info) { @@ -114690,6 +115907,7 @@ var ts; }; ProjectService.prototype.deleteScriptInfo = function (info) { this.filenameToScriptInfo.delete(info.path); + this.filenameToScriptInfoVersion.set(info.path, info.getVersion()); var realpath = info.getRealpathIfDifferent(); if (realpath) { this.realpathToScriptInfos.remove(realpath, info); @@ -115282,8 +116500,9 @@ 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.filenameToScriptInfoVersion.get(path)); this.filenameToScriptInfo.set(info.path, info); + this.filenameToScriptInfoVersion.delete(info.path); if (!openedByClient) { this.watchClosedScriptInfo(info); } @@ -115853,7 +117072,9 @@ var ts; function formatRelatedInformation(info) { if (!info.file) { return { - message: ts.flattenDiagnosticMessageText(info.messageText, "\n") + message: ts.flattenDiagnosticMessageText(info.messageText, "\n"), + category: ts.diagnosticCategoryName(info), + code: info.code }; } return { @@ -115862,7 +117083,9 @@ var ts; end: convertToLocation(ts.getLineAndCharacterOfPosition(info.file, info.start + info.length)), file: info.file.fileName }, - message: ts.flattenDiagnosticMessageText(info.messageText, "\n") + message: ts.flattenDiagnosticMessageText(info.messageText, "\n"), + category: ts.diagnosticCategoryName(info), + code: info.code }; } function convertToLocation(lineAndCharacter) { @@ -115888,13 +117111,7 @@ var ts; ? __assign({}, common, { fileName: diag.file && diag.file.fileName }) : common; } function allEditsBeforePos(edits, pos) { - for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var edit = edits_1[_i]; - if (ts.textSpanEnd(edit.span) >= pos) { - return false; - } - } - return true; + return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } server.CommandNames = server.protocol.CommandTypes; function formatMessage(msg, logger, byteLength, newLine) { @@ -116140,11 +117357,14 @@ var ts; _a[server.CommandNames.FormatRangeFull] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); }, + _a[server.CommandNames.CompletionInfo] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.CompletionInfo)); + }, _a[server.CommandNames.Completions] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, true)); + return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.Completions)); }, _a[server.CommandNames.CompletionsFull] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, false)); + return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.CompletionsFull)); }, _a[server.CommandNames.CompletionDetails] = function (request) { return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, true)); @@ -116940,7 +118160,7 @@ var ts; }; Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) { var file = server.toNormalizedPath(args.file); - var project = this.getProject(args.projectFileName) || this.projectService.getDefaultProjectForFile(file, false); + var project = this.getProject(args.projectFileName) || this.projectService.tryGetDefaultProjectForFile(file); if (!project) { return server.Errors.ThrowNoProject(); } @@ -116951,7 +118171,7 @@ var ts; }; Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName) { var file = server.toNormalizedPath(uncheckedFileName); - var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, true); + var project = this.getProject(projectFileName) || this.projectService.ensureDefaultProjectForFile(file); return { file: file, project: project }; }; Session.prototype.getOutliningSpans = function (args, simplifiedResult) { @@ -117103,25 +118323,28 @@ var ts; }; }); }; - Session.prototype.getCompletions = function (args, simplifiedResult) { + Session.prototype.getCompletions = function (args, kind) { var _this = this; - var prefix = args.prefix || ""; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign({}, this.getPreferences(file), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); - if (simplifiedResult) { - return ts.mapDefined(completions && completions.entries, function (entry) { - if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) { - var name = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, isRecommended = entry.isRecommended; - var convertedSpan = replacementSpan ? _this.toLocationTextSpan(replacementSpan, scriptInfo) : undefined; - return { name: name, kind: kind, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended }; - } - }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); - } - else { + if (completions === undefined) + return undefined; + if (kind === "completions-full") return completions; - } + var prefix = args.prefix || ""; + var entries = ts.mapDefined(completions.entries, function (entry) { + if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) { + var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, isRecommended = entry.isRecommended; + var convertedSpan = replacementSpan ? _this.toLocationTextSpan(replacementSpan, scriptInfo) : undefined; + return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended }; + } + }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); + if (kind === "completions") + return entries; + var res = __assign({}, completions, { entries: entries }); + return res; }; Session.prototype.getCompletionEntryDetails = function (args, simplifiedResult) { var _this = this; @@ -117173,7 +118396,7 @@ var ts; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); - var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); + var helpItems = project.getLanguageService().getSignatureHelpItems(file, position, args); if (!helpItems) { return undefined; } @@ -117198,7 +118421,7 @@ var ts; var _this = this; return ts.mapDefined(fileNames, function (uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); - var project = defaultProject || _this.projectService.getDefaultProjectForFile(fileName, false); + var project = defaultProject || _this.projectService.tryGetDefaultProjectForFile(fileName); return project && { fileName: fileName, project: project }; }); }; @@ -117311,6 +118534,8 @@ var ts; var bakedItem = { name: navItem.name, kind: navItem.kind, + isCaseSensitive: navItem.isCaseSensitive, + matchKind: navItem.matchKind, file: navItem.fileName, start: scriptInfo.positionToLineOffset(navItem.textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)) @@ -117318,9 +118543,6 @@ var ts; if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { bakedItem.kindModifiers = navItem.kindModifiers; } - if (navItem.matchKind !== "none") { - bakedItem.matchKind = navItem.matchKind; - } if (navItem.containerName && (navItem.containerName.length > 0)) { bakedItem.containerName = navItem.containerName; } @@ -117429,9 +118651,26 @@ var ts; } }; Session.prototype.getEditsForFileRename = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var changes = project.getLanguageService().getEditsForFileRename(server.toNormalizedPath(args.oldFilePath), server.toNormalizedPath(args.newFilePath), this.getFormatOptions(file), this.getPreferences(file)); - return simplifiedResult ? this.mapTextChangesToCodeEdits(project, changes) : changes; + var _this = this; + var oldPath = server.toNormalizedPath(args.oldFilePath); + var newPath = server.toNormalizedPath(args.newFilePath); + var formatOptions = this.getHostFormatOptions(); + var preferences = this.getHostPreferences(); + var changes = []; + this.projectService.forEachProject(function (project) { + if (project.isOrphan() || !project.languageServiceEnabled) + return; + var _loop_8 = function (fileTextChanges) { + if (!changes.some(function (f) { return f.fileName === fileTextChanges.fileName; })) { + changes.push(simplifiedResult ? _this.mapTextChangeToCodeEdit(project, fileTextChanges) : fileTextChanges); + } + }; + for (var _i = 0, _a = project.getLanguageService().getEditsForFileRename(oldPath, newPath, formatOptions, preferences); _i < _a.length; _i++) { + var fileTextChanges = _a[_i]; + _loop_8(fileTextChanges); + } + }); + return changes; }; Session.prototype.getCodeFixes = function (args, simplifiedResult) { var _this = this; @@ -117493,10 +118732,12 @@ var ts; }; Session.prototype.mapTextChangesToCodeEdits = function (project, textChanges) { var _this = this; - return textChanges.map(function (change) { - var path = server.normalizedPathToPath(server.toNormalizedPath(change.fileName), _this.host.getCurrentDirectory(), function (fileName) { return _this.getCanonicalFileName(fileName); }); - return mapTextChangesToCodeEdits(change, project.getSourceFileOrConfigFile(path)); - }); + return textChanges.map(function (change) { return _this.mapTextChangeToCodeEdit(project, change); }); + }; + Session.prototype.mapTextChangeToCodeEdit = function (project, change) { + var _this = this; + var path = server.normalizedPathToPath(server.toNormalizedPath(change.fileName), this.host.getCurrentDirectory(), function (fileName) { return _this.getCanonicalFileName(fileName); }); + return mapTextChangesToCodeEdits(change, project.getSourceFileOrConfigFile(path)); }; Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { return { @@ -117534,7 +118775,7 @@ var ts; var lowPriorityFiles = []; var veryLowPriorityFiles = []; var normalizedFileName = server.toNormalizedPath(fileName); - var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); + var project = this.projectService.ensureDefaultProjectForFile(normalizedFileName); for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { var fileNameInProject = fileNamesInProject_1[_i]; if (this.getCanonicalFileName(fileNameInProject) === this.getCanonicalFileName(fileName)) { @@ -117650,6 +118891,12 @@ var ts; Session.prototype.getPreferences = function (file) { return this.projectService.getPreferences(file); }; + Session.prototype.getHostFormatOptions = function () { + return this.projectService.getHostFormatCodeOptions(); + }; + Session.prototype.getHostPreferences = function () { + return this.projectService.getHostPreferences(); + }; return Session; }()); server.Session = Session; @@ -117685,8 +118932,8 @@ var ts; } server.getLocationInNewDocument = getLocationInNewDocument; function applyEdits(text, textFilename, edits) { - for (var _i = 0, edits_2 = edits; _i < edits_2.length; _i++) { - var _a = edits_2[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; if (fileName !== textFilename) { continue; } @@ -118548,7 +119795,7 @@ var ts; }); Logger.prototype.write = function (s) { if (this.fd >= 0) { - var buf = new Buffer(s); + var buf = Buffer.from ? Buffer.from(s) : new Buffer(s); // tslint:disable-next-line no-null-keyword fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null); // TODO: GH#18217 } @@ -119145,7 +120392,7 @@ var ts; sys.watchDirectory = watchDirectorySwallowingException; } // Override sys.write because fs.writeSync is not reliable on Node 4 - sys.write = function (s) { return writeMessage(new Buffer(s, "utf8")); }; + sys.write = function (s) { return writeMessage(Buffer.from ? Buffer.from(s, "utf8") : new Buffer(s, "utf8")); }; sys.watchFile = function (fileName, callback) { var watchedFile = pollingWatchedFileSet.addFile(fileName, callback); return { diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 44036c3fe28..ad8fd411384 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -148,7 +148,7 @@ declare namespace ts { */ function flatMap(array: ReadonlyArray, mapfn: (x: T, i: number) => U | ReadonlyArray | undefined): U[]; function flatMap(array: ReadonlyArray | undefined, mapfn: (x: T, i: number) => U | ReadonlyArray | undefined): U[] | undefined; - function flatMapIterator(iter: Iterator, mapfn: (x: T) => U[] | Iterator | undefined): Iterator; + function flatMapIterator(iter: Iterator, mapfn: (x: T) => ReadonlyArray | Iterator | undefined): Iterator; /** * Maps an array. If the mapped value is an array, it is spread into the result. * Avoids allocation if all elements map to themselves. @@ -241,7 +241,6 @@ declare namespace ts { * Returns a new sorted array. */ function sort(array: ReadonlyArray, comparer: Comparer): T[]; - function best(iter: Iterator, isBetter: (a: T, b: T) => boolean): T | undefined; function arrayIterator(array: ReadonlyArray): Iterator; /** * Stable sort of an array. Elements equal to each other maintain their relative position in the array. @@ -364,6 +363,7 @@ declare namespace ts { */ function isString(text: any): text is string; function tryCast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined; + function tryCast(value: T, test: (value: T) => boolean): T | undefined; function cast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut; /** Does nothing. */ function noop(_?: {} | null | undefined): void; @@ -531,7 +531,7 @@ declare namespace ts { function findBestPatternMatch(values: ReadonlyArray, getPattern: (value: T) => Pattern, candidate: string): T | undefined; function startsWith(str: string, prefix: string): boolean; function removePrefix(str: string, prefix: string): string; - function tryRemovePrefix(str: string, prefix: string): string | undefined; + function tryRemovePrefix(str: string, prefix: string, getCanonicalFileName?: GetCanonicalFileName): string | undefined; function and(f: (arg: T) => boolean, g: (arg: T) => boolean): (arg: T) => boolean; function or(f: (arg: T) => boolean, g: (arg: T) => boolean): (arg: T) => boolean; function assertTypeIsNever(_: never): void; @@ -763,144 +763,147 @@ declare namespace ts { 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, - JSDocThisTag = 295, - JSDocTypeTag = 296, - JSDocTemplateTag = 297, - JSDocTypedefTag = 298, - JSDocPropertyTag = 299, - SyntaxList = 300, - NotEmittedStatement = 301, - PartiallyEmittedExpression = 302, - CommaListExpression = 303, - MergeDeclarationMarker = 304, - EndOfDeclarationMarker = 305, - Count = 306, + OptionalType = 169, + RestType = 170, + UnionType = 171, + IntersectionType = 172, + ConditionalType = 173, + InferType = 174, + ParenthesizedType = 175, + ThisType = 176, + TypeOperator = 177, + IndexedAccessType = 178, + MappedType = 179, + LiteralType = 180, + ImportType = 181, + ObjectBindingPattern = 182, + ArrayBindingPattern = 183, + BindingElement = 184, + ArrayLiteralExpression = 185, + ObjectLiteralExpression = 186, + PropertyAccessExpression = 187, + ElementAccessExpression = 188, + CallExpression = 189, + NewExpression = 190, + TaggedTemplateExpression = 191, + TypeAssertionExpression = 192, + ParenthesizedExpression = 193, + FunctionExpression = 194, + ArrowFunction = 195, + DeleteExpression = 196, + TypeOfExpression = 197, + VoidExpression = 198, + AwaitExpression = 199, + PrefixUnaryExpression = 200, + PostfixUnaryExpression = 201, + BinaryExpression = 202, + ConditionalExpression = 203, + TemplateExpression = 204, + YieldExpression = 205, + SpreadElement = 206, + ClassExpression = 207, + OmittedExpression = 208, + ExpressionWithTypeArguments = 209, + AsExpression = 210, + NonNullExpression = 211, + MetaProperty = 212, + SyntheticExpression = 213, + TemplateSpan = 214, + SemicolonClassElement = 215, + Block = 216, + VariableStatement = 217, + EmptyStatement = 218, + ExpressionStatement = 219, + IfStatement = 220, + DoStatement = 221, + WhileStatement = 222, + ForStatement = 223, + ForInStatement = 224, + ForOfStatement = 225, + ContinueStatement = 226, + BreakStatement = 227, + ReturnStatement = 228, + WithStatement = 229, + SwitchStatement = 230, + LabeledStatement = 231, + ThrowStatement = 232, + TryStatement = 233, + DebuggerStatement = 234, + VariableDeclaration = 235, + VariableDeclarationList = 236, + FunctionDeclaration = 237, + ClassDeclaration = 238, + InterfaceDeclaration = 239, + TypeAliasDeclaration = 240, + EnumDeclaration = 241, + ModuleDeclaration = 242, + ModuleBlock = 243, + CaseBlock = 244, + NamespaceExportDeclaration = 245, + ImportEqualsDeclaration = 246, + ImportDeclaration = 247, + ImportClause = 248, + NamespaceImport = 249, + NamedImports = 250, + ImportSpecifier = 251, + ExportAssignment = 252, + ExportDeclaration = 253, + NamedExports = 254, + ExportSpecifier = 255, + MissingDeclaration = 256, + ExternalModuleReference = 257, + JsxElement = 258, + JsxSelfClosingElement = 259, + JsxOpeningElement = 260, + JsxClosingElement = 261, + JsxFragment = 262, + JsxOpeningFragment = 263, + JsxClosingFragment = 264, + JsxAttribute = 265, + JsxAttributes = 266, + JsxSpreadAttribute = 267, + JsxExpression = 268, + CaseClause = 269, + DefaultClause = 270, + HeritageClause = 271, + CatchClause = 272, + PropertyAssignment = 273, + ShorthandPropertyAssignment = 274, + SpreadAssignment = 275, + EnumMember = 276, + SourceFile = 277, + Bundle = 278, + UnparsedSource = 279, + InputFiles = 280, + JSDocTypeExpression = 281, + JSDocAllType = 282, + JSDocUnknownType = 283, + JSDocNullableType = 284, + JSDocNonNullableType = 285, + JSDocOptionalType = 286, + JSDocFunctionType = 287, + JSDocVariadicType = 288, + JSDocComment = 289, + JSDocTypeLiteral = 290, + JSDocSignature = 291, + JSDocTag = 292, + JSDocAugmentsTag = 293, + JSDocClassTag = 294, + JSDocCallbackTag = 295, + JSDocParameterTag = 296, + JSDocReturnTag = 297, + JSDocThisTag = 298, + JSDocTypeTag = 299, + JSDocTemplateTag = 300, + JSDocTypedefTag = 301, + JSDocPropertyTag = 302, + SyntaxList = 303, + NotEmittedStatement = 304, + PartiallyEmittedExpression = 305, + CommaListExpression = 306, + MergeDeclarationMarker = 307, + EndOfDeclarationMarker = 308, + Count = 309, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -912,7 +915,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 161, - LastTypeNode = 179, + LastTypeNode = 181, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -926,10 +929,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 146, - FirstJSDocNode = 278, - LastJSDocNode = 299, - FirstJSDocTagNode = 289, - LastJSDocTagNode = 299, + FirstJSDocNode = 281, + LastJSDocNode = 302, + FirstJSDocTagNode = 292, + LastJSDocTagNode = 302, FirstContextualKeyword = 117, LastContextualKeyword = 145 } @@ -1352,6 +1355,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } + interface OptionalTypeNode extends TypeNode { + kind: SyntaxKind.OptionalType; + type: TypeNode; + } + interface RestTypeNode extends TypeNode { + kind: SyntaxKind.RestType; + type: TypeNode; + } type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; @@ -1482,6 +1493,11 @@ declare namespace ts { asteriskToken?: AsteriskToken; expression?: Expression; } + interface SyntheticExpression extends Expression { + kind: SyntaxKind.SyntheticExpression; + isSpread: boolean; + type: Type; + } type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; @@ -1714,7 +1730,10 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; } @@ -2541,7 +2560,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -2567,8 +2585,9 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; + getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -2629,11 +2648,6 @@ declare namespace ts { writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string; writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; @@ -2675,7 +2689,7 @@ declare namespace ts { */ tryGetMemberInModuleExportsAndProperties(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined; + getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; @@ -2709,6 +2723,11 @@ declare namespace ts { getSymbolCount(): number; getTypeCount(): number; isArrayLikeType(type: Type): boolean; + /** + * True if `contextualType` should not be considered for completions because + * e.g. it specifies `kind: "a"` and obj has `kind: "b"`. + */ + isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression): boolean; /** * For a union, will include a property if it's defined in *any* of the member types. * So for `{ a } | { b }`, this will include both `a` and `b`. @@ -2821,25 +2840,6 @@ declare namespace ts { visitedSymbols: ReadonlyArray; }; } - /** - * @deprecated - */ - interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ interface SymbolWriter extends SymbolTracker { writeKeyword(text: string): void; writeOperator(text: string): void; @@ -2939,7 +2939,7 @@ declare namespace ts { getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean; isLateBound(node: Declaration): node is LateBoundDeclaration; - collectLinkedAliases(node: Identifier): Node[] | undefined; + collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined; isImplementationOfOverload(node: FunctionLike): boolean | undefined; isRequiredInitializedParameter(node: ParameterDeclaration): boolean; isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean; @@ -3072,6 +3072,7 @@ declare namespace ts { enumKind?: EnumKind; originatingImport?: ImportDeclaration | ImportCall; lateSymbol?: Symbol; + specifierCache?: Map; } enum EnumKind { Numeric = 0, @@ -3090,11 +3091,12 @@ declare namespace ts { ContainsStatic = 512, Late = 1024, ReverseMapped = 2048, + OptionalParameter = 4096, + RestParameter = 8192, Synthetic = 6 } interface TransientSymbol extends Symbol, SymbolLinks { checkFlags: CheckFlags; - isRestParameter?: boolean; } interface ReverseMappedSymbol extends TransientSymbol { propertyType: Type; @@ -3195,6 +3197,7 @@ declare namespace ts { hasSuperCall?: boolean; superCall?: SuperCall; switchTypes?: Type[]; + jsxNamespace?: Symbol | false; } enum TypeFlags { Any = 1, @@ -3270,7 +3273,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: Type[]; + aliasTypeArguments?: ReadonlyArray; wildcardInstantiation?: Type; } interface IntrinsicType extends Type { @@ -3311,6 +3314,12 @@ declare namespace ts { } interface ObjectType extends Type { objectFlags: ObjectFlags; + members?: SymbolTable; + properties?: Symbol[]; + callSignatures?: ReadonlyArray; + constructSignatures?: ReadonlyArray; + stringIndexInfo?: IndexInfo; + numberIndexInfo?: IndexInfo; } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ interface InterfaceType extends ObjectType { @@ -3341,7 +3350,7 @@ declare namespace ts { */ interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: Type[]; + typeArguments?: ReadonlyArray; } enum Variance { Invariant = 0, @@ -3354,6 +3363,14 @@ declare namespace ts { instantiations: Map; variances?: Variance[]; } + interface TupleType extends GenericType { + minLength: number; + hasRestElement: boolean; + associatedNames?: __String[]; + } + interface TupleTypeReference extends TypeReference { + target: TupleType; + } interface UnionOrIntersectionType extends Type { types: Type[]; propertyCache: SymbolTable; @@ -3391,10 +3408,8 @@ declare namespace ts { interface ResolvedType extends ObjectType, UnionOrIntersectionType { members: SymbolTable; properties: Symbol[]; - callSignatures: Signature[]; - constructSignatures: Signature[]; - stringIndexInfo?: IndexInfo; - numberIndexInfo?: IndexInfo; + callSignatures: ReadonlyArray; + constructSignatures: ReadonlyArray; } interface FreshObjectLiteralType extends ResolvedType { regularType: ResolvedType; @@ -3471,8 +3486,8 @@ declare namespace ts { } interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: TypeParameter[]; - parameters: Symbol[]; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; thisParameter?: Symbol; resolvedReturnType?: Type; resolvedTypePredicate?: TypePredicate; @@ -3538,7 +3553,7 @@ declare namespace ts { } type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary; interface InferenceContext extends TypeMapper { - typeParameters: TypeParameter[]; + typeParameters: ReadonlyArray; signature?: Signature; inferences: InferenceInfo[]; flags: InferenceFlags; @@ -3586,14 +3601,14 @@ declare namespace ts { next?: DiagnosticMessageChain; } interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -4268,6 +4283,7 @@ declare namespace ts { } interface EmitHost extends ScriptReferenceHost, ModuleSpecifierResolutionHost { getSourceFiles(): ReadonlyArray; + useCaseSensitiveFileNames(): boolean; getCurrentDirectory(): string; isSourceFileFromExternalLibrary(file: SourceFile): boolean; getCommonSourceDirectory(): string; @@ -4497,14 +4513,13 @@ declare namespace ts { readFile?(path: string): string | undefined; getSourceFiles?(): ReadonlyArray; } - /** @deprecated See comment on SymbolWriter */ interface SymbolTracker { trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError?(): void; reportPrivateInBaseOfClassExpression?(propertyName: string): void; reportInaccessibleUniqueSymbolError?(): void; moduleResolverHost?: ModuleSpecifierResolutionHost; - trackReferencedAmbientModule?(decl: ModuleDeclaration): void; + trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void; } interface TextSpan { start: number; @@ -4516,6 +4531,7 @@ declare namespace ts { } interface DiagnosticCollection { add(diagnostic: Diagnostic): void; + lookup(diagnostic: Diagnostic): Diagnostic | undefined; getGlobalDiagnostics(): Diagnostic[]; getDiagnostics(fileName: string): DiagnosticWithLocation[]; getDiagnostics(): Diagnostic[]; @@ -4921,7 +4937,6 @@ declare namespace ts { An_object_literal_cannot_have_property_and_accessor_with_the_same_name: DiagnosticMessage; An_export_assignment_cannot_have_modifiers: DiagnosticMessage; Octal_literals_are_not_allowed_in_strict_mode: DiagnosticMessage; - A_tuple_type_element_list_cannot_be_empty: DiagnosticMessage; Variable_declaration_list_cannot_be_empty: DiagnosticMessage; Digit_expected: DiagnosticMessage; Hexadecimal_digit_expected: DiagnosticMessage; @@ -5041,6 +5056,8 @@ declare namespace ts { _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: DiagnosticMessage; A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: DiagnosticMessage; A_definite_assignment_assertion_is_not_permitted_in_this_context: DiagnosticMessage; + A_rest_element_must_be_last_in_a_tuple_type: DiagnosticMessage; + A_required_element_cannot_follow_an_optional_element: DiagnosticMessage; with_statements_are_not_allowed_in_an_async_function_block: DiagnosticMessage; await_expression_is_only_allowed_within_an_async_function: DiagnosticMessage; can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: DiagnosticMessage; @@ -5071,7 +5088,7 @@ declare namespace ts { An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: DiagnosticMessage; infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: DiagnosticMessage; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: DiagnosticMessage; - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: DiagnosticMessage; + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: DiagnosticMessage; Type_arguments_cannot_be_used_here: DiagnosticMessage; The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: DiagnosticMessage; Duplicate_identifier_0: DiagnosticMessage; @@ -5141,6 +5158,7 @@ declare namespace ts { The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: DiagnosticMessage; Operator_0_cannot_be_applied_to_types_1_and_2: DiagnosticMessage; Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: DiagnosticMessage; + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: DiagnosticMessage; Type_parameter_name_cannot_be_0: DiagnosticMessage; A_parameter_property_is_only_allowed_in_a_constructor_implementation: DiagnosticMessage; A_rest_parameter_must_be_of_an_array_type: DiagnosticMessage; @@ -5190,6 +5208,7 @@ declare namespace ts { Class_0_incorrectly_extends_base_class_1: DiagnosticMessage; Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: DiagnosticMessage; Class_static_side_0_incorrectly_extends_base_class_static_side_1: DiagnosticMessage; + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: DiagnosticMessage; Class_0_incorrectly_implements_interface_1: DiagnosticMessage; A_class_may_only_implement_another_class_or_interface: DiagnosticMessage; Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: DiagnosticMessage; @@ -5337,6 +5356,9 @@ declare namespace ts { Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: DiagnosticMessage; Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: DiagnosticMessage; Object_is_of_type_unknown: DiagnosticMessage; + Rest_signatures_are_incompatible: DiagnosticMessage; + Property_0_is_incompatible_with_rest_element_type: DiagnosticMessage; + A_rest_element_type_must_be_an_array_type: DiagnosticMessage; JSX_element_attributes_type_0_may_not_be_a_union_type: DiagnosticMessage; The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: DiagnosticMessage; JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: DiagnosticMessage; @@ -5423,6 +5445,8 @@ declare namespace ts { Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: DiagnosticMessage; Cannot_find_lib_definition_for_0: DiagnosticMessage; Cannot_find_lib_definition_for_0_Did_you_mean_1: DiagnosticMessage; + _0_was_declared_here: DiagnosticMessage; + Property_0_is_used_before_its_initialization: DiagnosticMessage; Import_declaration_0_is_using_private_name_1: DiagnosticMessage; Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; @@ -5722,6 +5746,10 @@ declare namespace ts { Include_modules_imported_with_json_extension: DiagnosticMessage; All_destructured_elements_are_unused: DiagnosticMessage; All_variables_are_unused: DiagnosticMessage; + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: DiagnosticMessage; + Conflicts_are_in_this_file: DiagnosticMessage; + _0_was_also_declared_here: DiagnosticMessage; + and_here: DiagnosticMessage; Projects_to_reference: DiagnosticMessage; Enable_project_compilation: DiagnosticMessage; Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: DiagnosticMessage; @@ -5753,6 +5781,8 @@ declare namespace ts { Option_build_must_be_the_first_command_line_argument: DiagnosticMessage; Options_0_and_1_cannot_be_combined: DiagnosticMessage; Skipping_clean_because_not_all_projects_could_be_located: DiagnosticMessage; + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: DiagnosticMessage; + The_expected_type_comes_from_this_index_signature: DiagnosticMessage; Variable_0_implicitly_has_an_1_type: DiagnosticMessage; Parameter_0_implicitly_has_an_1_type: DiagnosticMessage; Member_0_implicitly_has_an_1_type: DiagnosticMessage; @@ -5784,6 +5814,7 @@ declare namespace ts { Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: DiagnosticMessage; Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: DiagnosticMessage; Mapped_object_type_implicitly_has_an_any_template_type: DiagnosticMessage; + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: DiagnosticMessage; You_cannot_rename_this_element: DiagnosticMessage; You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: DiagnosticMessage; import_can_only_be_used_in_a_ts_file: DiagnosticMessage; @@ -5928,6 +5959,10 @@ declare namespace ts { Add_or_remove_braces_in_an_arrow_function: DiagnosticMessage; Add_braces_to_arrow_function: DiagnosticMessage; Remove_braces_from_arrow_function: DiagnosticMessage; + Convert_default_export_to_named_export: DiagnosticMessage; + Convert_named_export_to_default_export: DiagnosticMessage; + Add_missing_enum_member_0: DiagnosticMessage; + Add_all_missing_imports: DiagnosticMessage; }; } declare namespace ts { @@ -6105,11 +6140,6 @@ declare namespace ts { function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile): string; function getTextOfConstantValue(value: string | number): string; function escapeLeadingUnderscores(identifier: string): __String; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier: string): string; function makeIdentifierFromModuleName(moduleName: string): string; function isBlockOrCatchScoped(declaration: Declaration): boolean; function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration): boolean; @@ -6138,7 +6168,7 @@ declare namespace ts { function isLateVisibilityPaintedStatement(node: Node): node is LateVisibilityPaintedStatement; function isAnyImportOrReExport(node: Node): node is AnyImportOrReExport; function getEnclosingBlockScopeContainer(node: Node): Node; - function declarationNameToString(name: DeclarationName | QualifiedName): string; + function declarationNameToString(name: DeclarationName | QualifiedName | undefined): string; function getNameFromIndexInfo(info: IndexInfo): string | undefined; function getTextOfPropertyName(name: PropertyName): __String; function entityNameToString(name: EntityNameOrEntityNameExpression): string; @@ -6150,8 +6180,8 @@ declare namespace ts { function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan; function isExternalOrCommonJsModule(file: SourceFile): boolean; function isJsonSourceFile(file: SourceFile): file is JsonSourceFile; - function isConstEnumDeclaration(node: Node): boolean; - function isConst(node: Node): boolean; + function isEnumConst(node: EnumDeclaration): boolean; + function isVarConst(node: VariableDeclaration | VariableDeclarationList): boolean; function isLet(node: Node): boolean; function isSuperCall(n: Node): n is SuperCall; function isImportCall(n: Node): n is ImportCall; @@ -6275,6 +6305,7 @@ declare namespace ts { function isExportsIdentifier(node: Node): boolean; function isModuleExportsPropertyAccessExpression(node: Node): boolean; function getSpecialPropertyAssignmentKind(expr: BinaryExpression): SpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs: PropertyAccessExpression): SpecialPropertyAssignmentKind; function getInitializerOfBinaryExpression(expr: BinaryExpression): Expression; function isPrototypePropertyAssignment(node: Node): boolean; function isSpecialPropertyDeclaration(expr: PropertyAccessExpression): boolean; @@ -6325,7 +6356,8 @@ declare namespace ts { function isIdentifierName(node: Identifier): boolean; function isAliasSymbolDeclaration(node: Node): boolean; function exportAssignmentIsAlias(node: ExportAssignment | BinaryExpression): boolean; - function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments | undefined; + function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments | undefined; + function getClassExtendsHeritageElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments | undefined; function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray | undefined; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node: Node): ReadonlyArray; @@ -6613,7 +6645,7 @@ declare namespace ts { function getObjectFlags(type: Type): ObjectFlags; function typeHasCallOrConstructSignatures(type: Type, checker: TypeChecker): boolean; function forSomeAncestorDirectory(directory: string, callback: (directory: string) => boolean): boolean; - function isUMDExportSymbol(symbol: Symbol | undefined): boolean | undefined; + function isUMDExportSymbol(symbol: Symbol | undefined): boolean; function showModuleSpecifier({ moduleSpecifier }: ImportDeclaration): string; function getLastChild(node: Node): Node | undefined; /** Add a value to a set, and return true if it wasn't already present. */ @@ -6626,6 +6658,7 @@ declare namespace ts { function textSpanEnd(span: TextSpan): number; function textSpanIsEmpty(span: TextSpan): boolean; function textSpanContainsPosition(span: TextSpan, position: number): boolean; + function textRangeContainsPositionInclusive(span: TextRange, position: number): boolean; function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan | undefined; @@ -6658,7 +6691,8 @@ declare namespace ts { function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; + function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; + function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** * Checks to see if the locale is in the appropriate format, @@ -6704,19 +6738,14 @@ declare namespace ts { function unescapeLeadingUnderscores(identifier: __String): string; function idText(identifier: Identifier): string; function symbolName(symbol: Symbol): string; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; /** @internal */ function isNamedDeclaration(node: Node): node is NamedDeclaration & { name: DeclarationName; }; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -6961,7 +6990,7 @@ declare namespace ts { function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken; function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier; - function isModifierKind(token: SyntaxKind): boolean; + function isModifierKind(token: SyntaxKind): token is Modifier["kind"]; function isParameterPropertyModifier(kind: SyntaxKind): boolean; function isClassMemberModifier(idToken: SyntaxKind): boolean; function isModifier(node: Node): node is Modifier; @@ -7092,6 +7121,7 @@ declare namespace ts { function chainDiagnosticMessages(details: DiagnosticMessageChain | undefined, message: DiagnosticMessage, ...args: (string | undefined)[]): DiagnosticMessageChain; function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison; + function compareDiagnosticsSkipRelatedInformation(d1: Diagnostic, d2: Diagnostic): Comparison; function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; function getEmitModuleKind(compilerOptions: { module?: CompilerOptions["module"]; @@ -7283,7 +7313,7 @@ declare namespace ts { function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; function containsPath(parent: string, child: string, ignoreCase?: boolean): boolean; function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; - function tryRemoveDirectoryPrefix(path: string, dirPath: string): string | undefined; + function tryRemoveDirectoryPrefix(path: string, dirPath: string, getCanonicalFileName: GetCanonicalFileName): string | undefined; function hasExtension(fileName: string): boolean; const commonPackageFolders: ReadonlyArray; function getRegularExpressionForWildcard(specs: ReadonlyArray | undefined, basePath: string, usage: "files" | "directories" | "exclude"): string | undefined; @@ -7381,6 +7411,9 @@ declare namespace ts { * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ function matchPatternOrExact(patternStrings: ReadonlyArray, candidate: string): string | Pattern | undefined; + type Mutable = { + -readonly [K in keyof T]: T[K]; + }; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -7733,8 +7766,8 @@ declare namespace ts { /** Create a unique name based on the supplied text. This does not consider names injected by the transformer. */ function createFileLevelUniqueName(text: string): Identifier; /** Create a unique name generated for a node. */ - function getGeneratedNameForNode(node: Node): Identifier; - function getGeneratedNameForNode(node: Node, flags: GeneratedIdentifierFlags): Identifier; + function getGeneratedNameForNode(node: Node | undefined): Identifier; + function getGeneratedNameForNode(node: Node | undefined, flags: GeneratedIdentifierFlags): Identifier; function createToken(token: TKind): Token; function createSuper(): SuperExpression; function createThis(): ThisExpression & Token; @@ -7790,7 +7823,11 @@ declare namespace ts { function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTypleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; + function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; + function createRestTypeNode(type: TypeNode): RestTypeNode; + function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; @@ -7845,7 +7882,7 @@ declare namespace ts { 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; + /** @deprecated */ function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; @@ -7863,7 +7900,7 @@ declare namespace ts { function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): BinaryExpression; function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; - function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + /** @deprecated */ function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; @@ -7891,13 +7928,16 @@ declare namespace ts { function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function createExpressionStatement(expression: Expression): ExpressionStatement; function updateBlock(node: Block, statements: ReadonlyArray): Block; function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; - function createStatement(expression: Expression): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createExpressionStatement(expression: Expression): ExpressionStatement; + function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + const createStatement: typeof createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + const updateStatement: typeof updateExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; @@ -8346,6 +8386,9 @@ declare namespace ts { function parenthesizeElementTypeMembers(members: ReadonlyArray): NodeArray; function parenthesizeTypeParameters(typeParameters: ReadonlyArray | undefined): MutableNodeArray | undefined; function parenthesizeConciseBody(body: ConciseBody): ConciseBody; + function isCommaSequence(node: Expression): node is (BinaryExpression & { + operatorToken: Token; + }) | CommaListExpression; enum OuterExpressionKinds { Parentheses = 1, Assertions = 2, @@ -8576,17 +8619,6 @@ declare namespace ts.sourcemaps { readonly lastSpan: SourceMapSpan; } function decodeMappings(map: SourceMapData): MappingsDecoder; - function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { - log?(s: string): void; - }): T[]; - interface RawSourceMapPosition { - emittedLine: number; - emittedColumn: number; - sourceLine: number; - sourceColumn: number; - sourceIndex: number; - nameIndex?: number; - } } declare namespace ts { function getOriginalNodeId(node: Node): number; @@ -8918,6 +8950,7 @@ declare namespace ts { } /** @internal */ function formatColorAndReset(text: string, formatStyle: string): string; + function formatLocation(file: SourceFile, start: number, host: FormatDiagnosticsHost, color?: typeof formatColorAndReset): string; function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain | undefined, newLine: string): string; /** @@ -9265,9 +9298,9 @@ declare namespace ts { } declare namespace ts.moduleSpecifiers { interface ModuleSpecifierPreferences { - importModuleSpecifierPreference?: "relative" | "non-relative"; + readonly importModuleSpecifierPreference?: "relative" | "non-relative"; } - function getModuleSpecifier(compilerOptions: CompilerOptions, fromSourceFile: SourceFile, fromSourceFileName: string, toFileName: string, host: ModuleSpecifierResolutionHost, preferences?: ModuleSpecifierPreferences): string; + function getModuleSpecifier(compilerOptions: CompilerOptions, importingSourceFile: SourceFile, importingSourceFileName: Path, toFileName: string, host: ModuleSpecifierResolutionHost, files: ReadonlyArray, preferences?: ModuleSpecifierPreferences): string; function getModuleSpecifiers(moduleSymbol: Symbol, compilerOptions: CompilerOptions, importingSourceFile: SourceFile, host: ModuleSpecifierResolutionHost, files: ReadonlyArray, preferences: ModuleSpecifierPreferences): ReadonlyArray>; } declare namespace ts { @@ -9521,12 +9554,12 @@ declare namespace ts { */ interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** * One or more of the outputs of the project does not exist. @@ -9829,8 +9862,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; + getCallSignatures(): ReadonlyArray; + getConstructSignatures(): ReadonlyArray; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -9859,7 +9892,7 @@ declare namespace ts { version: string; scriptSnapshot: IScriptSnapshot | undefined; nameTable: UnderscoreEscapedMap | undefined; - getNamedDeclarations(): Map; + getNamedDeclarations(): Map>; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; getLineStarts(): ReadonlyArray; @@ -9956,7 +9989,7 @@ declare namespace ts { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; } - const defaultPreferences: UserPreferences; + const emptyOptions: {}; interface LanguageService { cleanupSemanticCache(): void; getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; @@ -9980,7 +10013,7 @@ declare namespace ts { 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; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; @@ -10041,13 +10074,54 @@ declare namespace ts { type OrganizeImportsScope = CombinedCodeFixScope; type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } interface ApplyCodeActionCommandResult { successMessage: string; } @@ -10238,7 +10312,7 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; @@ -10695,11 +10769,13 @@ declare namespace ts { } function getLineStartPositionForPosition(position: number, sourceFile: SourceFileLike): number; function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; + function rangeContainsRangeExclusive(r1: TextRange, r2: TextRange): boolean; function rangeContainsPosition(r: TextRange, pos: number): boolean; function rangeContainsPositionExclusive(r: TextRange, pos: number): boolean; function startEndContainsRange(start: number, end: number, range: TextRange): boolean; function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; + function nodeOverlapsWithStartEnd(node: Node, sourceFile: SourceFile, start: number, end: number): boolean; function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; /** * Assumes `candidate.start <= position` holds. @@ -10718,9 +10794,9 @@ declare namespace ts { * Returns the token if position is in [start, end). * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true */ - function getTouchingToken(sourceFile: SourceFile, position: number, includeJsDocComment: boolean, includePrecedingTokenAtEndPosition?: (n: Node) => boolean): Node; + function getTouchingToken(sourceFile: SourceFile, position: number, includePrecedingTokenAtEndPosition?: (n: Node) => boolean): Node; /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment: boolean, includeEndPosition?: boolean): Node; + function getTokenAtPosition(sourceFile: SourceFile, position: number): Node; /** * The token on the left of the position is the token that strictly includes the position * or sits to the left of the cursor if it is on a boundary. For example @@ -10735,7 +10811,7 @@ declare namespace ts { * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, includeJsDoc?: boolean): Node | undefined; + function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, excludeJsdoc?: boolean): Node | undefined; function isInString(sourceFile: SourceFile, position: number, previousToken?: Node | undefined): boolean; /** * returns true if the position is in between the open and close elements of an JSX expression. @@ -10754,8 +10830,8 @@ declare namespace ts { * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - function isInComment(sourceFile: SourceFile, position: number, tokenAtPosition?: Node, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean | undefined; + function isInComment(sourceFile: SourceFile, position: number, tokenAtPosition?: Node): CommentRange | undefined; + function hasDocComment(sourceFile: SourceFile, position: number): boolean; function getNodeModifiers(node: Node): string; function getTypeArgumentOrTypeParameterList(node: Node): NodeArray | undefined; function isComment(kind: SyntaxKind): boolean; @@ -10794,6 +10870,7 @@ declare namespace ts { Single = 0, Double = 1 } + function quotePreferenceFromString(str: StringLiteral, sourceFile: SourceFile): QuotePreference; function getQuotePreference(sourceFile: SourceFile, preferences: UserPreferences): QuotePreference; function symbolNameNoDefault(symbol: Symbol): string | undefined; function symbolEscapedNameNoDefault(symbol: Symbol): __String | undefined; @@ -10810,14 +10887,32 @@ declare namespace ts { */ function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, checker: TypeChecker, cb: (symbol: Symbol) => T | undefined): T | undefined; function isMemberSymbolInBaseType(memberSymbol: Symbol, checker: TypeChecker): boolean; - class NodeSet { + interface ReadonlyNodeSet { + has(node: Node): boolean; + forEach(cb: (node: Node) => void): void; + some(pred: (node: Node) => boolean): boolean; + } + class NodeSet implements ReadonlyNodeSet { private map; add(node: Node): void; has(node: Node): boolean; forEach(cb: (node: Node) => void): void; some(pred: (node: Node) => boolean): boolean; } + interface ReadonlyNodeMap { + get(node: TNode): TValue | undefined; + has(node: TNode): boolean; + } + class NodeMap implements ReadonlyNodeMap { + private map; + get(node: TNode): TValue | undefined; + getOrUpdate(node: TNode, setValue: () => TValue): TValue; + set(node: TNode, value: TValue): void; + has(node: TNode): boolean; + forEach(cb: (value: TValue, node: TNode) => void): void; + } function getParentNodeInSpan(node: Node | undefined, file: SourceFile, span: TextSpan): Node | undefined; + function findModifier(node: Node, kind: Modifier["kind"]): Modifier | undefined; function insertImport(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importDecl: Statement): void; } declare namespace ts { @@ -10906,7 +11001,7 @@ declare namespace ts.Completions { name: string; source?: string; } - function getCompletionEntryDetails(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost, formatContext: formatting.FormatContext, getCanonicalFileName: GetCanonicalFileName, preferences: UserPreferences, cancellationToken: CancellationToken): CompletionEntryDetails | undefined; + function getCompletionEntryDetails(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost, formatContext: formatting.FormatContext, preferences: UserPreferences, cancellationToken: CancellationToken): CompletionEntryDetails | undefined; function getCompletionEntrySymbol(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier): Symbol | undefined; } declare namespace ts.DocumentHighlights { @@ -10995,7 +11090,7 @@ declare namespace ts.FindAllReferences { } type ImportTracker = (exportSymbol: Symbol, exportInfo: ExportInfo, isForRename: boolean) => ImportsResult; /** Creates the imports map and returns an ImportTracker that uses it. Call this lazily to avoid calling `getDirectImportsMap` unnecessarily. */ - function createImportTracker(sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap, checker: TypeChecker, cancellationToken: CancellationToken): ImportTracker; + function createImportTracker(sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap, checker: TypeChecker, cancellationToken: CancellationToken | undefined): ImportTracker; /** Info about an exported symbol to perform recursive search on. */ interface ExportInfo { exportingModuleSymbol: Symbol; @@ -11087,7 +11182,7 @@ declare namespace ts.FindAllReferences { } function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined; function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ImplementationLocation[] | undefined; - function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number, options?: Options): ReferenceEntry[] | undefined; + function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, node: Node, position: number, options: Options | undefined): ReferenceEntry[] | undefined; function getReferenceEntriesForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options?: Options, sourceFilesSet?: ReadonlyMap): Entry[] | undefined; function toHighlightSpan(entry: Entry): { fileName: string; @@ -11098,9 +11193,11 @@ declare namespace ts.FindAllReferences { declare namespace ts.FindAllReferences.Core { /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */ function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options?: Options, sourceFilesSet?: ReadonlyMap): SymbolAndEntries[] | undefined; + function eachExportReference(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken | undefined, exportSymbol: Symbol, exportingModuleSymbol: Symbol, exportName: string, isDefaultExport: boolean, cb: (ref: Identifier) => void): void; /** Used as a quick check for whether a symbol is used at all in a file (besides its definition). */ function isSymbolReferencedInFile(definition: Identifier, checker: TypeChecker, sourceFile: SourceFile): boolean; function eachSymbolReferenceInFile(definition: Identifier, checker: TypeChecker, sourceFile: SourceFile, cb: (token: Identifier) => T): T | undefined; + function eachSignatureCall(signature: SignatureDeclaration, sourceFiles: ReadonlyArray, checker: TypeChecker, cb: (call: CallExpression) => void): void; /** * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class @@ -11114,6 +11211,9 @@ declare namespace ts.FindAllReferences.Core { } declare namespace ts { function getEditsForFileRename(program: Program, oldFileOrDirPath: string, newFileOrDirPath: string, host: LanguageServiceHost, formatContext: formatting.FormatContext, preferences: UserPreferences): ReadonlyArray; + /** If 'path' refers to an old directory, returns path in the new directory. */ + type PathUpdater = (path: string) => string | undefined; + function getPathUpdater(oldFileOrDirPath: string, newFileOrDirPath: string, getCanonicalFileName: GetCanonicalFileName): PathUpdater; } declare namespace ts.GoToDefinition { function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[] | undefined; @@ -11211,10 +11311,10 @@ declare namespace ts { function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; } declare namespace ts.Rename { - function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: GetCanonicalFileName, sourceFile: SourceFile, position: number): RenameInfo; + function getRenameInfo(program: Program, sourceFile: SourceFile, position: number): RenameInfo; } declare namespace ts.SignatureHelp { - function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems | undefined; + function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, triggerReason: SignatureHelpTriggerReason | undefined, cancellationToken: CancellationToken): SignatureHelpItems | undefined; interface ArgumentInfoForCompletions { readonly invocation: CallLikeExpression; readonly argumentIndex: number; @@ -11362,8 +11462,8 @@ declare namespace ts.formatting { /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, onlyMultiLine: boolean, precedingToken?: Node | null, // tslint:disable-line:no-null-keyword - tokenAtPosition?: Node, predicate?: (c: CommentRange) => boolean): CommentRange | undefined; + function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, precedingToken?: Node | null, // tslint:disable-line:no-null-keyword + tokenAtPosition?: Node): CommentRange | undefined; function getIndentationString(indentation: number, options: EditorSettings): string; } declare namespace ts.formatting { @@ -11474,18 +11574,17 @@ declare namespace ts.textChanges { private readonly formatContext; private readonly changes; private readonly newFiles; - private readonly deletedNodesInLists; private readonly classesWithNodesInsertedAtStart; + private readonly deletedNodes; static fromContext(context: TextChangesContext): ChangeTracker; static with(context: TextChangesContext, cb: (tracker: ChangeTracker) => void): FileTextChanges[]; /** Public for tests only. Other callers should use `ChangeTracker.with`. */ constructor(newLineCharacter: string, formatContext: formatting.FormatContext); deleteRange(sourceFile: SourceFile, range: TextRange): this; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - deleteNode(sourceFile: SourceFile, node: Node, options?: ConfigurableStartEnd): this; + delete(sourceFile: SourceFile, node: Node): void; + deleteModifier(sourceFile: SourceFile, modifier: Modifier): void; deleteNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options?: ConfigurableStartEnd): this; deleteNodeRangeExcludingEnd(sourceFile: SourceFile, startNode: Node, afterEndNode: Node | undefined, options?: ConfigurableStartEnd): void; - deleteNodeInList(sourceFile: SourceFile, node: Node): this; replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options?: InsertNodeOptions): this; replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options?: ChangeNodeOptions): this; replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options?: ChangeNodeOptions): void; @@ -11494,7 +11593,7 @@ declare namespace ts.textChanges { replaceNodeRangeWithNodes(sourceFile: SourceFile, startNode: Node, endNode: Node, newNodes: ReadonlyArray, options?: ReplaceWithMultipleNodesOptions & ConfigurableStartEnd): this; private nextCommaToken; replacePropertyAssignment(sourceFile: SourceFile, oldNode: PropertyAssignment, newNode: PropertyAssignment): this; - private insertNodeAt; + insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options?: InsertNodeOptions): void; private insertNodesAt; insertNodeAtTopOfFile(sourceFile: SourceFile, newNode: Statement, blankLineBetween: boolean): void; insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, blankLineBetween?: boolean): void; @@ -11514,6 +11613,7 @@ declare namespace ts.textChanges { private getInsertNodeAtClassStartPrefixSuffix; insertNodeAfterComma(sourceFile: SourceFile, after: Node, newNode: Node): void; insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node): void; + insertNodeAtEndOfList(sourceFile: SourceFile, list: NodeArray, newNode: Node): void; insertNodesAfter(sourceFile: SourceFile, after: Node, newNodes: ReadonlyArray): void; private insertNodeAfterWorker; private getInsertNodeAfterOptions; @@ -11527,7 +11627,7 @@ declare namespace ts.textChanges { */ insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node, containingList?: NodeArray | undefined): this; private finishClassesWithNodesInsertedAtStart; - private finishTrailingCommaAfterDeletingNodesInList; + private finishDeleteDeclarations; /** * Note: after calling this, the TextChanges object must be discarded! * @param validate only for tests @@ -11538,14 +11638,16 @@ declare namespace ts.textChanges { createNewFile(oldFile: SourceFile, fileName: string, statements: ReadonlyArray): void; } type ValidateNonFormattedText = (node: Node, text: string) => void; - function applyChanges(text: string, changes: TextChange[]): string; + function applyChanges(text: string, changes: ReadonlyArray): string; function isValidLocationToAddComment(sourceFile: SourceFile, position: number): boolean; + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + function deleteNode(changes: ChangeTracker, sourceFile: SourceFile, node: Node, options?: ConfigurableStartEnd): void; } declare namespace ts { interface CodeFixRegistration { - errorCodes: number[]; + errorCodes: ReadonlyArray; getCodeActions(context: CodeFixContext): CodeFixAction[] | undefined; - fixIds?: string[]; + fixIds?: ReadonlyArray; getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions; } interface CodeFixContextBase extends textChanges.TextChangesContext { @@ -11569,8 +11671,10 @@ declare namespace ts { function getSupportedErrorCodes(): string[]; function getFixes(context: CodeFixContext): CodeFixAction[]; function getAllFixes(context: CodeFixAllContext): CombinedCodeActions; + function createCombinedCodeActions(changes: FileTextChanges[], commands?: CodeActionCommand[]): CombinedCodeActions; function createFileTextChanges(fileName: string, textChanges: TextChange[]): FileTextChanges; function codeFixAll(context: CodeFixAllContext, errorCodes: number[], use: (changes: textChanges.ChangeTracker, error: DiagnosticWithLocation, commands: Push) => void): CombinedCodeActions; + function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: ReadonlyArray, cb: (diag: DiagnosticWithLocation) => void): void; } } declare namespace ts { @@ -11611,7 +11715,8 @@ declare namespace ts.codefix { declare namespace ts.codefix { } declare namespace ts.codefix { - function getImportCompletionAction(exportedSymbol: Symbol, moduleSymbol: Symbol, sourceFile: SourceFile, symbolName: string, host: LanguageServiceHost, program: Program, checker: TypeChecker, compilerOptions: CompilerOptions, allSourceFiles: ReadonlyArray, formatContext: formatting.FormatContext, getCanonicalFileName: GetCanonicalFileName, symbolToken: Node | undefined, preferences: UserPreferences): { + const importFixId = "fixMissingImport"; + function getImportCompletionAction(exportedSymbol: Symbol, moduleSymbol: Symbol, sourceFile: SourceFile, symbolName: string, host: LanguageServiceHost, program: Program, checker: TypeChecker, allSourceFiles: ReadonlyArray, formatContext: formatting.FormatContext, symbolToken: Node | undefined, preferences: UserPreferences): { readonly moduleSpecifier: string; readonly codeAction: CodeAction; }; @@ -11655,7 +11760,7 @@ declare namespace ts.codefix { * @returns Empty string iff there are no member insertions. */ function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: ReadonlyArray, checker: TypeChecker, preferences: UserPreferences, out: (node: ClassElement) => void): void; - function createMethodFromCallExpression({ typeArguments, arguments: args, parent: parent }: CallExpression, methodName: string, inJs: boolean, makeStatic: boolean, preferences: UserPreferences): MethodDeclaration; + function createMethodFromCallExpression(context: CodeFixContextBase, { typeArguments, arguments: args, parent: parent }: CallExpression, methodName: string, inJs: boolean, makeStatic: boolean, preferences: UserPreferences): MethodDeclaration; } declare namespace ts.codefix { } @@ -11671,7 +11776,9 @@ declare namespace ts.codefix { } declare namespace ts.codefix { } -declare namespace ts.refactor.generateGetAccessorAndSetAccessor { +declare namespace ts.refactor { +} +declare namespace ts.refactor { } declare namespace ts.refactor.extractSymbol { /** @@ -11867,7 +11974,7 @@ declare namespace ts { */ readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; /** - * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules + * Read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules */ readFile(fileName: string): string | undefined; realpath?(path: string): string; @@ -11905,7 +12012,7 @@ declare namespace ts { getQuickInfoAtPosition(fileName: string, position: number): string; getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string; getBreakpointStatementAtPosition(fileName: string, position: number): string; - getSignatureHelpItems(fileName: string, position: number): string; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): string; /** * Returns a JSON-encoded value of the type: * { canRename: boolean, localizedErrorMessage: string, displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, triggerSpan: { start; length } } @@ -12204,6 +12311,7 @@ declare namespace ts.server.protocol { Change = "change", Close = "close", Completions = "completions", + CompletionInfo = "completionInfo", CompletionsFull = "completions-full", CompletionDetails = "completionEntryDetails", CompletionDetailsFull = "completionEntryDetails-full", @@ -12467,7 +12575,7 @@ declare namespace ts.server.protocol { command: CommandTypes.GetEditsForFileRename; arguments: GetEditsForFileRenameRequestArgs; } - interface GetEditsForFileRenameRequestArgs extends FileRequestArgs { + interface GetEditsForFileRenameRequestArgs { readonly oldFilePath: string; readonly newFilePath: string; } @@ -12905,6 +13013,15 @@ declare namespace ts.server.protocol { interface CompletionsResponse extends Response { body?: CompletionEntry[]; } + interface CompletionInfoResponse extends Response { + body?: CompletionInfo; + } + interface CompletionInfo { + readonly isGlobalCompletion: boolean; + readonly isMemberCompletion: boolean; + readonly isNewIdentifierLocation: boolean; + readonly entries: ReadonlyArray; + } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } @@ -12930,7 +13047,23 @@ declare namespace ts.server.protocol { argumentIndex: number; argumentCount: number; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + triggerCharacter: SignatureHelpTriggerCharacter; + } + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + triggerCharacter?: SignatureHelpRetriggerCharacter; } interface SignatureHelpRequest extends FileLocationRequest { command: CommandTypes.SignatureHelp; @@ -13003,6 +13136,8 @@ declare namespace ts.server.protocol { fileName: string; } interface DiagnosticRelatedInformation { + category: string; + code: number; message: string; span?: FileSpan; } @@ -13066,15 +13201,12 @@ declare namespace ts.server.protocol { command: CommandTypes.Navto; arguments: NavtoRequestArgs; } - interface NavtoItem { + interface NavtoItem extends FileSpan { name: string; kind: ScriptElementKind; - matchKind?: string; - isCaseSensitive?: boolean; + matchKind: string; + isCaseSensitive: boolean; kindModifiers?: string; - file: string; - start: Location; - end: Location; containerName?: string; containerKind?: ScriptElementKind; } @@ -13312,18 +13444,21 @@ declare namespace ts.server.protocol { } } declare namespace ts.server { + interface ScriptInfoVersion { + svc: number; + text: number; + } class TextStorage { private readonly host; private readonly fileName; + version: ScriptInfoVersion; private svc; - private svcVersion; private text; private lineMap; - private textVersion; isOpen: boolean; private ownFileText; private pendingReloadFromDisk; - constructor(host: ServerHost, fileName: NormalizedPath); + constructor(host: ServerHost, fileName: NormalizedPath, initialVersion?: ScriptInfoVersion); getVersion(): string; hasScriptVersionCache_TestOnly(): boolean; useScriptVersionCache_TestOnly(): void; @@ -13363,7 +13498,8 @@ declare namespace ts.server { readonly isDynamic: boolean; private realpath; cacheSourceFile: DocumentRegistrySourceFileCache; - constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path); + constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path, initialVersion?: ScriptInfoVersion); + getVersion(): ScriptInfoVersion; isDynamicOrHasMixedContent(): boolean; isScriptOpen(): boolean; open(newText: string): void; @@ -13773,6 +13909,7 @@ declare namespace ts.server { readonly typingsCache: TypingsCache; readonly documentRegistry: DocumentRegistry; private readonly filenameToScriptInfo; + private readonly filenameToScriptInfoVersion; private readonly allJsFilesForOpenFileTelemetry; readonly realpathToScriptInfos: MultiMap | undefined; private readonly externalProjectToConfiguredProjectMap; @@ -13830,11 +13967,17 @@ declare namespace ts.server { private delayUpdateProjectGraphs; setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void; findProject(projectName: string): Project | undefined; + forEachProject(cb: (project: Project) => void): void; getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined; + tryGetDefaultProjectForFile(fileName: NormalizedPath): Project | undefined; + ensureDefaultProjectForFile(fileName: NormalizedPath): Project; + private doEnsureDefaultProjectForFile; getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo | undefined; private ensureProjectStructuresUptoDate; getFormatCodeOptions(file: NormalizedPath): FormatCodeSettings; getPreferences(file: NormalizedPath): UserPreferences; + getHostFormatCodeOptions(): FormatCodeSettings; + getHostPreferences(): UserPreferences; private onSourceFileChanged; private handleDeletedFile; watchWildcardDirectory(directory: Path, flags: WatchDirectoryFlags, project: ConfiguredProject): FileWatcher; @@ -14065,6 +14208,7 @@ declare namespace ts.server { private mapCodeAction; private mapCodeFixAction; private mapTextChangesToCodeEdits; + private mapTextChangeToCodeEdit; private convertTextChangeToCodeEdit; private getBraceMatching; private getDiagnosticsForProject; @@ -14081,6 +14225,8 @@ declare namespace ts.server { onMessage(message: string): void; private getFormatOptions; private getPreferences; + private getHostFormatOptions; + private getHostPreferences; } interface HandlerResponse { response?: {}; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index d9addcbcdbf..440e7824b60 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -242,144 +242,147 @@ declare namespace ts { 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, - JSDocThisTag = 295, - JSDocTypeTag = 296, - JSDocTemplateTag = 297, - JSDocTypedefTag = 298, - JSDocPropertyTag = 299, - SyntaxList = 300, - NotEmittedStatement = 301, - PartiallyEmittedExpression = 302, - CommaListExpression = 303, - MergeDeclarationMarker = 304, - EndOfDeclarationMarker = 305, - Count = 306, + OptionalType = 169, + RestType = 170, + UnionType = 171, + IntersectionType = 172, + ConditionalType = 173, + InferType = 174, + ParenthesizedType = 175, + ThisType = 176, + TypeOperator = 177, + IndexedAccessType = 178, + MappedType = 179, + LiteralType = 180, + ImportType = 181, + ObjectBindingPattern = 182, + ArrayBindingPattern = 183, + BindingElement = 184, + ArrayLiteralExpression = 185, + ObjectLiteralExpression = 186, + PropertyAccessExpression = 187, + ElementAccessExpression = 188, + CallExpression = 189, + NewExpression = 190, + TaggedTemplateExpression = 191, + TypeAssertionExpression = 192, + ParenthesizedExpression = 193, + FunctionExpression = 194, + ArrowFunction = 195, + DeleteExpression = 196, + TypeOfExpression = 197, + VoidExpression = 198, + AwaitExpression = 199, + PrefixUnaryExpression = 200, + PostfixUnaryExpression = 201, + BinaryExpression = 202, + ConditionalExpression = 203, + TemplateExpression = 204, + YieldExpression = 205, + SpreadElement = 206, + ClassExpression = 207, + OmittedExpression = 208, + ExpressionWithTypeArguments = 209, + AsExpression = 210, + NonNullExpression = 211, + MetaProperty = 212, + SyntheticExpression = 213, + TemplateSpan = 214, + SemicolonClassElement = 215, + Block = 216, + VariableStatement = 217, + EmptyStatement = 218, + ExpressionStatement = 219, + IfStatement = 220, + DoStatement = 221, + WhileStatement = 222, + ForStatement = 223, + ForInStatement = 224, + ForOfStatement = 225, + ContinueStatement = 226, + BreakStatement = 227, + ReturnStatement = 228, + WithStatement = 229, + SwitchStatement = 230, + LabeledStatement = 231, + ThrowStatement = 232, + TryStatement = 233, + DebuggerStatement = 234, + VariableDeclaration = 235, + VariableDeclarationList = 236, + FunctionDeclaration = 237, + ClassDeclaration = 238, + InterfaceDeclaration = 239, + TypeAliasDeclaration = 240, + EnumDeclaration = 241, + ModuleDeclaration = 242, + ModuleBlock = 243, + CaseBlock = 244, + NamespaceExportDeclaration = 245, + ImportEqualsDeclaration = 246, + ImportDeclaration = 247, + ImportClause = 248, + NamespaceImport = 249, + NamedImports = 250, + ImportSpecifier = 251, + ExportAssignment = 252, + ExportDeclaration = 253, + NamedExports = 254, + ExportSpecifier = 255, + MissingDeclaration = 256, + ExternalModuleReference = 257, + JsxElement = 258, + JsxSelfClosingElement = 259, + JsxOpeningElement = 260, + JsxClosingElement = 261, + JsxFragment = 262, + JsxOpeningFragment = 263, + JsxClosingFragment = 264, + JsxAttribute = 265, + JsxAttributes = 266, + JsxSpreadAttribute = 267, + JsxExpression = 268, + CaseClause = 269, + DefaultClause = 270, + HeritageClause = 271, + CatchClause = 272, + PropertyAssignment = 273, + ShorthandPropertyAssignment = 274, + SpreadAssignment = 275, + EnumMember = 276, + SourceFile = 277, + Bundle = 278, + UnparsedSource = 279, + InputFiles = 280, + JSDocTypeExpression = 281, + JSDocAllType = 282, + JSDocUnknownType = 283, + JSDocNullableType = 284, + JSDocNonNullableType = 285, + JSDocOptionalType = 286, + JSDocFunctionType = 287, + JSDocVariadicType = 288, + JSDocComment = 289, + JSDocTypeLiteral = 290, + JSDocSignature = 291, + JSDocTag = 292, + JSDocAugmentsTag = 293, + JSDocClassTag = 294, + JSDocCallbackTag = 295, + JSDocParameterTag = 296, + JSDocReturnTag = 297, + JSDocThisTag = 298, + JSDocTypeTag = 299, + JSDocTemplateTag = 300, + JSDocTypedefTag = 301, + JSDocPropertyTag = 302, + SyntaxList = 303, + NotEmittedStatement = 304, + PartiallyEmittedExpression = 305, + CommaListExpression = 306, + MergeDeclarationMarker = 307, + EndOfDeclarationMarker = 308, + Count = 309, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -391,7 +394,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 161, - LastTypeNode = 179, + LastTypeNode = 181, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -405,10 +408,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 146, - FirstJSDocNode = 278, - LastJSDocNode = 299, - FirstJSDocTagNode = 289, - LastJSDocTagNode = 299 + FirstJSDocNode = 281, + LastJSDocNode = 302, + FirstJSDocTagNode = 292, + LastJSDocTagNode = 302 } enum NodeFlags { None = 0, @@ -767,6 +770,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } + interface OptionalTypeNode extends TypeNode { + kind: SyntaxKind.OptionalType; + type: TypeNode; + } + interface RestTypeNode extends TypeNode { + kind: SyntaxKind.RestType; + type: TypeNode; + } type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; @@ -891,6 +902,11 @@ declare namespace ts { asteriskToken?: AsteriskToken; expression?: Expression; } + interface SyntheticExpression extends Expression { + kind: SyntaxKind.SyntheticExpression; + isSpread: boolean; + type: Type; + } type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; @@ -1105,7 +1121,10 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; } @@ -1780,6 +1799,7 @@ declare namespace ts { */ getTypeChecker(): TypeChecker; isSourceFileFromExternalLibrary(file: SourceFile): boolean; + isSourceFileDefaultLibrary(file: SourceFile): boolean; getProjectReferences(): (ResolvedProjectReference | undefined)[] | undefined; } interface ResolvedProjectReference { @@ -1818,7 +1838,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -1838,7 +1857,7 @@ declare namespace ts { getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1889,11 +1908,6 @@ declare namespace ts { typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): string; typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; @@ -1920,7 +1934,7 @@ declare namespace ts { getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined; + getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; @@ -1992,39 +2006,6 @@ declare namespace ts { AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8 } - /** - * @deprecated - */ - interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ - interface SymbolWriter extends SymbolTracker { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeProperty(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - } enum TypePredicateKind { This = 0, Identifier = 1 @@ -2214,7 +2195,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: Type[]; + aliasTypeArguments?: ReadonlyArray; } interface LiteralType extends Type { value: string | number; @@ -2279,10 +2260,18 @@ declare namespace ts { */ interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: Type[]; + typeArguments?: ReadonlyArray; } interface GenericType extends InterfaceType, TypeReference { } + interface TupleType extends GenericType { + minLength: number; + hasRestElement: boolean; + associatedNames?: __String[]; + } + interface TupleTypeReference extends TypeReference { + target: TupleType; + } interface UnionOrIntersectionType extends Type { types: Type[]; } @@ -2339,8 +2328,8 @@ declare namespace ts { } interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: TypeParameter[]; - parameters: Symbol[]; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; } enum IndexKind { String = 0, @@ -2388,14 +2377,14 @@ declare namespace ts { next?: DiagnosticMessageChain; } interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -2929,13 +2918,6 @@ declare namespace ts { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - /** @deprecated See comment on SymbolWriter */ - interface SymbolTracker { - trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError?(): void; - reportPrivateInBaseOfClassExpression?(propertyName: string): void; - reportInaccessibleUniqueSymbolError?(): void; - } interface TextSpan { start: number; length: number; @@ -3166,7 +3148,8 @@ declare namespace ts { function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; + function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; + function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** * Checks to see if the locale is in the appropriate format, @@ -3212,15 +3195,8 @@ declare namespace ts { function unescapeLeadingUnderscores(identifier: __String): string; function idText(identifier: Identifier): string; function symbolName(symbol: Symbol): string; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -3655,7 +3631,7 @@ declare namespace ts { /** Create a unique name based on the supplied text. This does not consider names injected by the transformer. */ function createFileLevelUniqueName(text: string): Identifier; /** Create a unique name generated for a node. */ - function getGeneratedNameForNode(node: Node): Identifier; + function getGeneratedNameForNode(node: Node | undefined): Identifier; function createToken(token: TKind): Token; function createSuper(): SuperExpression; function createThis(): ThisExpression & Token; @@ -3710,7 +3686,11 @@ declare namespace ts { function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTypleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; + function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; + function createRestTypeNode(type: TypeNode): RestTypeNode; + function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; @@ -3763,7 +3743,7 @@ declare namespace ts { 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; + /** @deprecated */ function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; @@ -3781,7 +3761,7 @@ declare namespace ts { function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): BinaryExpression; function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; - function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + /** @deprecated */ function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; @@ -3813,8 +3793,12 @@ declare namespace ts { function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; - function createStatement(expression: Expression): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createExpressionStatement(expression: Expression): ExpressionStatement; + function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + const createStatement: typeof createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + const updateStatement: typeof updateExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; @@ -4504,12 +4488,12 @@ declare namespace ts { */ interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** * One or more of the outputs of the project does not exist. @@ -4629,8 +4613,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; + getCallSignatures(): ReadonlyArray; + getConstructSignatures(): ReadonlyArray; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4771,7 +4755,7 @@ declare namespace ts { 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; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; @@ -4831,13 +4815,54 @@ declare namespace ts { type OrganizeImportsScope = CombinedCodeFixScope; type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } interface ApplyCodeActionCommandResult { successMessage: string; } @@ -5025,7 +5050,7 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; diff --git a/lib/typescript.js b/lib/typescript.js index c1ead6a1fac..4785ced00f3 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -26,6 +26,33 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + 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; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; @@ -889,23 +916,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1866,8 +1876,9 @@ 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; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2207,160 +2218,163 @@ var ts; 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["OptionalType"] = 169] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; // Expression - 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["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; // Element - 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["Block"] = 216] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; // JSX - 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["JsxElement"] = 258] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; // The ? type - 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["JSDocThisTag"] = 295] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 296] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 297] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 298] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 299] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 296] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 297] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 298] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 299] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 300] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 301] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 302] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 300] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 303] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 301] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 302] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 303] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 304] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 305] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 304] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 305] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 306] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 307] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 308] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 306] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 309] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -2373,7 +2387,7 @@ var ts; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; @@ -2387,10 +2401,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 299] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 299] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 302] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 302] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -2564,6 +2578,7 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; @@ -2783,6 +2798,8 @@ var ts; CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; CheckFlags[CheckFlags["Late"] = 1024] = "Late"; CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped"; + CheckFlags[CheckFlags["OptionalParameter"] = 4096] = "OptionalParameter"; + CheckFlags[CheckFlags["RestParameter"] = 8192] = "RestParameter"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var InternalSymbolName; @@ -4417,6 +4434,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -4575,7 +4595,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -4695,6 +4714,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -4725,7 +4746,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -4795,6 +4816,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -4844,6 +4866,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -4991,6 +5014,9 @@ var ts; 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'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), 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."), @@ -5077,6 +5103,8 @@ var ts; 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}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), 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}'."), @@ -5376,6 +5404,10 @@ var ts; 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), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), 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}"), @@ -5407,6 +5439,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -5438,6 +5472,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -5582,6 +5617,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -7730,7 +7769,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274 /* SourceFile */) { + while (node && node.kind !== 277 /* SourceFile */) { node = node.parent; } return node; @@ -7738,11 +7777,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return true; } return false; @@ -7880,7 +7919,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 === 300 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 303 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7973,14 +8012,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { @@ -7994,7 +8025,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; + return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -8026,11 +8057,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 === 239 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 /* SourceFile */ || - node.kind === 239 /* ModuleDeclaration */ || + return node.kind === 277 /* SourceFile */ || + node.kind === 242 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8047,9 +8078,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 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node.parent); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8061,22 +8092,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 269 /* CatchClause */: - case 239 /* ModuleDeclaration */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 272 /* CatchClause */: + case 242 /* ModuleDeclaration */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; - case 213 /* Block */: + case 216 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8092,22 +8123,22 @@ var ts; 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 297 /* JSDocTemplateTag */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: - case 288 /* JSDocSignature */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 291 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -8117,8 +8148,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8127,15 +8158,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - 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 */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 217 /* VariableStatement */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -8156,7 +8187,7 @@ var ts; // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -8183,7 +8214,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8228,7 +8259,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213 /* Block */) { + if (node.body && node.body.kind === 216 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8242,7 +8273,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* 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 @@ -8251,25 +8282,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 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 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: errorNode = node.name; break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8301,35 +8332,34 @@ var ts; return file.scriptKind === 6 /* JSON */; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */ && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */) - || !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 /* ImportType */ && - n.argument.kind === 178 /* LiteralType */ && + return n.kind === 181 /* ImportType */ && + n.argument.kind === 180 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 /* ExpressionStatement */ + return node.kind === 219 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -8340,9 +8370,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 /* Parameter */ || node.kind === 148 /* TypeParameter */ || - node.kind === 192 /* FunctionExpression */ || - node.kind === 193 /* ArrowFunction */ || - node.kind === 191 /* ParenthesizedExpression */) ? + node.kind === 194 /* FunctionExpression */ || + node.kind === 195 /* ArrowFunction */ || + node.kind === 193 /* 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 '/**/' @@ -8358,7 +8388,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -8372,11 +8402,11 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 196 /* VoidExpression */; - case 207 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 198 /* VoidExpression */; + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148 /* TypeParameter */: - return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; + return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: @@ -8384,20 +8414,20 @@ var ts; if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 187 /* 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 === 146 /* QualifiedName */ || node.kind === 185 /* 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 === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through case 146 /* QualifiedName */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: { var parent = node.parent; if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 179 /* ImportType */) { + if (parent.kind === 181 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8406,22 +8436,22 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148 /* TypeParameter */: return node === parent.constraint; case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return node === parent.type; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -8432,12 +8462,12 @@ var ts; case 159 /* ConstructSignature */: case 160 /* IndexSignature */: return node === parent.type; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return node === parent.type; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8462,23 +8492,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitor(node); - 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 */: + case 244 /* CaseBlock */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8488,19 +8518,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -8543,12 +8573,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 166 /* TypeLiteral */: return node.members; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.properties; } } @@ -8556,14 +8586,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182 /* BindingElement */: - case 273 /* EnumMember */: + case 184 /* BindingElement */: + case 276 /* EnumMember */: case 149 /* Parameter */: - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 271 /* ShorthandPropertyAssignment */: - case 232 /* VariableDeclaration */: + case 274 /* ShorthandPropertyAssignment */: + case 235 /* VariableDeclaration */: return true; } } @@ -8575,12 +8605,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 /* VariableDeclarationList */ - && node.parent.parent.kind === 214 /* VariableStatement */; + return node.parent.kind === 236 /* VariableDeclarationList */ + && node.parent.parent.kind === 217 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -8592,8 +8622,8 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return true; } return false; @@ -8604,7 +8634,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228 /* LabeledStatement */) { + if (node.statement.kind !== 231 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -8612,17 +8642,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 184 /* ObjectLiteralExpression */ || - node.parent.kind === 205 /* ClassExpression */); + (node.parent.kind === 186 /* ObjectLiteralExpression */ || + node.parent.kind === 207 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8635,7 +8665,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270 /* PropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -8672,7 +8702,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274 /* SourceFile */); + ts.Debug.assert(node.kind !== 277 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -8707,14 +8737,14 @@ var ts; node = node.parent; } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 239 /* ModuleDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 242 /* ModuleDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 154 /* MethodDeclaration */: @@ -8725,8 +8755,8 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 238 /* EnumDeclaration */: - case 274 /* SourceFile */: + case 241 /* EnumDeclaration */: + case 277 /* SourceFile */: return node; } } @@ -8737,8 +8767,8 @@ var ts; if (container) { switch (container.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return container; } } @@ -8763,9 +8793,9 @@ var ts; case 147 /* ComputedPropertyName */: node = node.parent; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!stopOnFunctions) { continue; } @@ -8796,14 +8826,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { + if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 191 /* ParenthesizedExpression */) { + while (parent.kind === 193 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -8814,7 +8844,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -8823,7 +8853,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -8831,7 +8861,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -8844,10 +8874,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return node.tag; - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -8856,25 +8886,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // classes are valid targets return true; case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 235 /* ClassDeclaration */; + return parent.kind === 238 /* 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 === 235 /* ClassDeclaration */; + && parent.kind === 238 /* 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 === 155 /* Constructor */ || parent.kind === 154 /* MethodDeclaration */ || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 235 /* ClassDeclaration */; + && grandparent.kind === 238 /* ClassDeclaration */; } return false; } @@ -8890,7 +8920,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 case 154 /* MethodDeclaration */: case 157 /* SetAccessor */: @@ -8902,9 +8932,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 /* JsxOpeningElement */ || - parent.kind === 256 /* JsxSelfClosingElement */ || - parent.kind === 258 /* JsxClosingElement */) { + if (parent.kind === 260 /* JsxOpeningElement */ || + parent.kind === 259 /* JsxSelfClosingElement */ || + parent.kind === 261 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -8917,37 +8947,37 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - 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 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: + case 210 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 211 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 206 /* SpreadElement */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 206 /* OmittedExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 203 /* YieldExpression */: - case 197 /* AwaitExpression */: - case 210 /* MetaProperty */: + case 208 /* OmittedExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 205 /* YieldExpression */: + case 199 /* AwaitExpression */: + case 212 /* MetaProperty */: return true; case 146 /* QualifiedName */: while (node.parent.kind === 146 /* QualifiedName */) { @@ -8971,47 +9001,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 182 /* BindingElement */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 184 /* BindingElement */: return parent.initializer === node; - 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 */: + case 219 /* ExpressionStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 228 /* ReturnStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 232 /* ThrowStatement */: return parent.expression === node; - case 220 /* ForStatement */: + case 223 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forInStatement.expression === node; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return node === parent.expression; - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return node === parent.expression; case 147 /* ComputedPropertyName */: return node === parent.expression; case 150 /* Decorator */: - case 265 /* JsxExpression */: - case 264 /* JsxSpreadAttribute */: - case 272 /* SpreadAssignment */: + case 268 /* JsxExpression */: + case 267 /* JsxSpreadAttribute */: + case 275 /* SpreadAssignment */: return true; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -9019,7 +9049,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9028,7 +9058,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -9060,7 +9090,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187 /* CallExpression */) { + if (callExpression.kind !== 189 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -9156,11 +9186,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 192 /* FunctionExpression */ || - initializer.kind === 205 /* ClassExpression */ || - initializer.kind === 193 /* ArrowFunction */) { + if (initializer.kind === 194 /* FunctionExpression */ || + initializer.kind === 207 /* ClassExpression */ || + initializer.kind === 195 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9229,7 +9259,7 @@ var ts; return false; } function getRightMostAssignedExpression(node) { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -9252,6 +9282,14 @@ var ts; return 0 /* None */; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + // F.prototype = { ... } + return 6 /* Prototype */; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } @@ -9260,11 +9298,7 @@ var ts; return 2 /* ModuleExports */; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - // F.prototype = { ... } - return 6 /* Prototype */; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } @@ -9284,7 +9318,7 @@ var ts; } return 0 /* None */; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -9298,7 +9332,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9308,14 +9342,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.parent; - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return node.parent.parent; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return node.parent; - case 178 /* LiteralType */: + case 180 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9325,12 +9359,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.moduleSpecifier; - case 243 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 179 /* ImportType */: + case 246 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 181 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9339,11 +9373,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9351,7 +9385,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -9360,8 +9394,8 @@ var ts; case 149 /* Parameter */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 271 /* ShorthandPropertyAssignment */: - case 270 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return node.questionToken !== undefined; @@ -9371,14 +9405,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 /* JSDocFunctionType */ && + return node.kind === 287 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 301 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9403,12 +9437,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152 /* PropertyDeclaration */: return node.initializer; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return node.initializer; } } @@ -9418,59 +9452,57 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 /* ModuleDeclaration */ + node.body.kind === 242 /* ModuleDeclaration */ ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - 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. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } - } - // Pull parameter comments from declaring function as well - 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)) { - result = ts.addRange(result, node.initializer.jsDoc); - } + // Pull parameter comments from declaring function as well + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } + if (node.kind === 149 /* Parameter */) { + result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; + } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 /* PropertyAssignment */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + return parent; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -9519,7 +9551,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9532,31 +9564,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 191 /* ParenthesizedExpression */: - case 183 /* ArrayLiteralExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 185 /* ArrayLiteralExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: node = parent; break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -9583,22 +9615,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - 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 */: + case 216 /* Block */: + case 217 /* VariableStatement */: + case 229 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return true; } return false; @@ -9615,15 +9647,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173 /* ParenthesizedType */); + return walkUp(node, 175 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191 /* ParenthesizedExpression */); + return walkUp(node, 193 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */) { + while (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -9631,11 +9663,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 !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194 /* DeleteExpression */; + return node && node.kind === 196 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9692,9 +9724,9 @@ var ts; case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 185 /* PropertyAccessExpression */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 187 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; case 146 /* QualifiedName */: @@ -9706,12 +9738,12 @@ var ts; return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 182 /* BindingElement */: - case 248 /* ImportSpecifier */: + case 184 /* BindingElement */: + case 251 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 252 /* ExportSpecifier */: - case 262 /* JsxAttribute */: + case 255 /* ExportSpecifier */: + case 265 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -9727,13 +9759,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(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) || + return node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 245 /* NamespaceExportDeclaration */ || + node.kind === 248 /* ImportClause */ && !!node.name || + node.kind === 249 /* NamespaceImport */ || + node.kind === 251 /* ImportSpecifier */ || + node.kind === 255 /* ExportSpecifier */ || + node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9742,11 +9774,22 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + // Prefer an @augments tag because it may have type parameters. + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; @@ -9755,7 +9798,7 @@ var ts; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -9828,14 +9871,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -9849,9 +9892,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined @@ -9957,7 +10000,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182 /* BindingElement */) { + while (node.kind === 184 /* BindingElement */) { node = node.parent.parent; } return node; @@ -9966,14 +10009,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 /* Constructor */ - || kind === 192 /* FunctionExpression */ - || kind === 234 /* FunctionDeclaration */ - || kind === 193 /* ArrowFunction */ + || kind === 194 /* FunctionExpression */ + || kind === 237 /* FunctionDeclaration */ + || kind === 195 /* ArrowFunction */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ - || kind === 239 /* ModuleDeclaration */ - || kind === 274 /* SourceFile */; + || kind === 242 /* ModuleDeclaration */ + || kind === 277 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9992,23 +10035,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: return 1 /* Right */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -10032,15 +10075,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200 /* BinaryExpression */) { + if (expression.kind === 202 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { + else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10050,15 +10093,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return 0; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return 1; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return 2; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return 4; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -10079,21 +10122,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: return 16; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return 17; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return 18; - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 19 : 18; - case 189 /* TaggedTemplateExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 191 /* TaggedTemplateExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -10103,19 +10146,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - 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 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 191 /* ParenthesizedExpression */: - case 206 /* OmittedExpression */: + case 204 /* TemplateExpression */: + case 193 /* ParenthesizedExpression */: + case 208 /* OmittedExpression */: return 20; default: return -1; @@ -10174,6 +10217,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -10181,6 +10225,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -10603,7 +10664,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 289 /* 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); @@ -10615,7 +10676,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -10908,8 +10969,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 184 /* ObjectLiteralExpression */ - || kind === 183 /* ArrayLiteralExpression */; + return kind === 186 /* ObjectLiteralExpression */ + || kind === 185 /* ArrayLiteralExpression */; } return false; } @@ -10919,7 +10980,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */ + return node.kind === 209 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -10941,16 +11002,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); + (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 /* ObjectLiteralExpression */ && + return expression.kind === 186 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 /* ArrayLiteralExpression */ && + return expression.kind === 185 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11291,8 +11352,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11369,21 +11430,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 185 /* PropertyAccessExpression */: + case 187 /* 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 === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -11486,7 +11547,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -11556,6 +11617,11 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + /* @internal */ + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; // Returns true if 'span' contains 'other'. function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -11749,7 +11815,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { return current; } } @@ -11774,27 +11840,34 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232 /* VariableDeclaration */) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236 /* VariableDeclarationList */) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217 /* VariableStatement */) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags @@ -11804,19 +11877,7 @@ var ts; // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** @@ -11924,16 +11985,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -11950,17 +12001,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return expr.name; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11969,10 +12020,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 228 /* LabeledStatement */: { + case 231 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11984,7 +12035,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -11995,29 +12046,20 @@ 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; - } + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71 /* Identifier */: return declaration; - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: { + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -12029,17 +12071,22 @@ var ts; return undefined; } } - case 292 /* JSDocCallbackTag */: - return declaration.name; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -12328,545 +12375,545 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169 /* UnionType */; + return node.kind === 171 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170 /* IntersectionType */; + return node.kind === 172 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171 /* ConditionalType */; + return node.kind === 173 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172 /* InferType */; + return node.kind === 174 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173 /* ParenthesizedType */; + return node.kind === 175 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174 /* ThisType */; + return node.kind === 176 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175 /* TypeOperator */; + return node.kind === 177 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176 /* IndexedAccessType */; + return node.kind === 178 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177 /* MappedType */; + return node.kind === 179 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178 /* LiteralType */; + return node.kind === 180 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179 /* ImportType */; + return node.kind === 181 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 180 /* ObjectBindingPattern */; + return node.kind === 182 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181 /* ArrayBindingPattern */; + return node.kind === 183 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182 /* BindingElement */; + return node.kind === 184 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 183 /* ArrayLiteralExpression */; + return node.kind === 185 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184 /* ObjectLiteralExpression */; + return node.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185 /* PropertyAccessExpression */; + return node.kind === 187 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186 /* ElementAccessExpression */; + return node.kind === 188 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187 /* CallExpression */; + return node.kind === 189 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188 /* NewExpression */; + return node.kind === 190 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189 /* TaggedTemplateExpression */; + return node.kind === 191 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190 /* TypeAssertionExpression */; + return node.kind === 192 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191 /* ParenthesizedExpression */; + return node.kind === 193 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302 /* PartiallyEmittedExpression */) { + while (node.kind === 305 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192 /* FunctionExpression */; + return node.kind === 194 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193 /* ArrowFunction */; + return node.kind === 195 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194 /* DeleteExpression */; + return node.kind === 196 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195 /* TypeOfExpression */; + return node.kind === 197 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196 /* VoidExpression */; + return node.kind === 198 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197 /* AwaitExpression */; + return node.kind === 199 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198 /* PrefixUnaryExpression */; + return node.kind === 200 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199 /* PostfixUnaryExpression */; + return node.kind === 201 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200 /* BinaryExpression */; + return node.kind === 202 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201 /* ConditionalExpression */; + return node.kind === 203 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202 /* TemplateExpression */; + return node.kind === 204 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203 /* YieldExpression */; + return node.kind === 205 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204 /* SpreadElement */; + return node.kind === 206 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205 /* ClassExpression */; + return node.kind === 207 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206 /* OmittedExpression */; + return node.kind === 208 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208 /* AsExpression */; + return node.kind === 210 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209 /* NonNullExpression */; + return node.kind === 211 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210 /* MetaProperty */; + return node.kind === 212 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 211 /* TemplateSpan */; + return node.kind === 214 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212 /* SemicolonClassElement */; + return node.kind === 215 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 213 /* Block */; + return node.kind === 216 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214 /* VariableStatement */; + return node.kind === 217 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215 /* EmptyStatement */; + return node.kind === 218 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216 /* ExpressionStatement */; + return node.kind === 219 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217 /* IfStatement */; + return node.kind === 220 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218 /* DoStatement */; + return node.kind === 221 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219 /* WhileStatement */; + return node.kind === 222 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220 /* ForStatement */; + return node.kind === 223 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221 /* ForInStatement */; + return node.kind === 224 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222 /* ForOfStatement */; + return node.kind === 225 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223 /* ContinueStatement */; + return node.kind === 226 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224 /* BreakStatement */; + return node.kind === 227 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; + return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225 /* ReturnStatement */; + return node.kind === 228 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226 /* WithStatement */; + return node.kind === 229 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227 /* SwitchStatement */; + return node.kind === 230 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228 /* LabeledStatement */; + return node.kind === 231 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229 /* ThrowStatement */; + return node.kind === 232 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230 /* TryStatement */; + return node.kind === 233 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231 /* DebuggerStatement */; + return node.kind === 234 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232 /* VariableDeclaration */; + return node.kind === 235 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233 /* VariableDeclarationList */; + return node.kind === 236 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234 /* FunctionDeclaration */; + return node.kind === 237 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235 /* ClassDeclaration */; + return node.kind === 238 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236 /* InterfaceDeclaration */; + return node.kind === 239 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237 /* TypeAliasDeclaration */; + return node.kind === 240 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */; + return node.kind === 241 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */; + return node.kind === 242 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240 /* ModuleBlock */; + return node.kind === 243 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241 /* CaseBlock */; + return node.kind === 244 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242 /* NamespaceExportDeclaration */; + return node.kind === 245 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */; + return node.kind === 246 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244 /* ImportDeclaration */; + return node.kind === 247 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245 /* ImportClause */; + return node.kind === 248 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246 /* NamespaceImport */; + return node.kind === 249 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247 /* NamedImports */; + return node.kind === 250 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248 /* ImportSpecifier */; + return node.kind === 251 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249 /* ExportAssignment */; + return node.kind === 252 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250 /* ExportDeclaration */; + return node.kind === 253 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251 /* NamedExports */; + return node.kind === 254 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252 /* ExportSpecifier */; + return node.kind === 255 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253 /* MissingDeclaration */; + return node.kind === 256 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 254 /* ExternalModuleReference */; + return node.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 255 /* JsxElement */; + return node.kind === 258 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256 /* JsxSelfClosingElement */; + return node.kind === 259 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257 /* JsxOpeningElement */; + return node.kind === 260 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258 /* JsxClosingElement */; + return node.kind === 261 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259 /* JsxFragment */; + return node.kind === 262 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260 /* JsxOpeningFragment */; + return node.kind === 263 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261 /* JsxClosingFragment */; + return node.kind === 264 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262 /* JsxAttribute */; + return node.kind === 265 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263 /* JsxAttributes */; + return node.kind === 266 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264 /* JsxSpreadAttribute */; + return node.kind === 267 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265 /* JsxExpression */; + return node.kind === 268 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 266 /* CaseClause */; + return node.kind === 269 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267 /* DefaultClause */; + return node.kind === 270 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268 /* HeritageClause */; + return node.kind === 271 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269 /* CatchClause */; + return node.kind === 272 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 270 /* PropertyAssignment */; + return node.kind === 273 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271 /* ShorthandPropertyAssignment */; + return node.kind === 274 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272 /* SpreadAssignment */; + return node.kind === 275 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 274 /* SourceFile */; + return node.kind === 277 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275 /* Bundle */; + return node.kind === 278 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276 /* UnparsedSource */; + return node.kind === 279 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 278 /* JSDocTypeExpression */; + return node.kind === 281 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279 /* JSDocAllType */; + return node.kind === 282 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280 /* JSDocUnknownType */; + return node.kind === 283 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281 /* JSDocNullableType */; + return node.kind === 284 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282 /* JSDocNonNullableType */; + return node.kind === 285 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283 /* JSDocOptionalType */; + return node.kind === 286 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284 /* JSDocFunctionType */; + return node.kind === 287 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285 /* JSDocVariadicType */; + return node.kind === 288 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286 /* JSDocComment */; + return node.kind === 289 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290 /* JSDocAugmentsTag */; + return node.kind === 293 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291 /* JSDocClassTag */; + return node.kind === 294 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295 /* JSDocThisTag */; + return node.kind === 298 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293 /* JSDocParameterTag */; + return node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294 /* JSDocReturnTag */; + return node.kind === 297 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296 /* JSDocTypeTag */; + return node.kind === 299 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297 /* JSDocTemplateTag */; + return node.kind === 300 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298 /* JSDocTypedefTag */; + return node.kind === 301 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299 /* JSDocPropertyTag */; + return node.kind === 302 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; + return node.kind === 302 /* JSDocPropertyTag */ || node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287 /* JSDocTypeLiteral */; + return node.kind === 290 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288 /* JSDocSignature */; + return node.kind === 291 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -12877,7 +12924,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 300 /* SyntaxList */; + return n.kind === 303 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -12992,8 +13039,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 180 /* ObjectBindingPattern */ - || kind === 181 /* ArrayBindingPattern */; + || kind === 182 /* ObjectBindingPattern */ + || kind === 183 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13008,13 +13055,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; default: return false; @@ -13025,11 +13072,11 @@ var ts; switch (kind) { case 153 /* MethodSignature */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: case 164 /* ConstructorType */: return true; default: @@ -13051,11 +13098,11 @@ var ts; || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ || kind === 160 /* IndexSignature */ - || kind === 212 /* SemicolonClassElement */; + || kind === 215 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); + return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -13090,9 +13137,9 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 /* PropertyAssignment */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 272 /* SpreadAssignment */ + return kind === 273 /* PropertyAssignment */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 275 /* SpreadAssignment */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */; @@ -13100,7 +13147,7 @@ var ts; ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ @@ -13113,14 +13160,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 207 /* ExpressionWithTypeArguments */ - || kind === 279 /* JSDocAllType */ - || kind === 280 /* JSDocUnknownType */ - || kind === 281 /* JSDocNullableType */ - || kind === 282 /* JSDocNonNullableType */ - || kind === 283 /* JSDocOptionalType */ - || kind === 284 /* JSDocFunctionType */ - || kind === 285 /* JSDocVariadicType */; + || kind === 209 /* ExpressionWithTypeArguments */ + || kind === 282 /* JSDocAllType */ + || kind === 283 /* JSDocUnknownType */ + || kind === 284 /* JSDocNullableType */ + || kind === 285 /* JSDocNonNullableType */ + || kind === 286 /* JSDocOptionalType */ + || kind === 287 /* JSDocFunctionType */ + || kind === 288 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13145,8 +13192,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 /* ArrayBindingPattern */ - || kind === 180 /* ObjectBindingPattern */; + return kind === 183 /* ArrayBindingPattern */ + || kind === 182 /* ObjectBindingPattern */; } return false; } @@ -13154,15 +13201,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 /* ArrayLiteralExpression */ - || kind === 184 /* ObjectLiteralExpression */; + return kind === 185 /* ArrayLiteralExpression */ + || kind === 186 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 /* BindingElement */ - || kind === 206 /* OmittedExpression */; + return kind === 184 /* BindingElement */ + || kind === 208 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13171,9 +13218,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return true; } return false; @@ -13194,8 +13241,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return true; } return false; @@ -13207,8 +13254,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return true; } return false; @@ -13217,25 +13264,25 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */ - || kind === 179 /* ImportType */; + || kind === 181 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: case 150 /* Decorator */: return true; default: @@ -13244,12 +13291,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; + return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 /* TemplateExpression */ + return kind === 204 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13260,32 +13307,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - 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 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 190 /* NewExpression */: + case 189 /* CallExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 191 /* TaggedTemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 193 /* ParenthesizedExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 209 /* NonNullExpression */: - case 210 /* MetaProperty */: + case 211 /* NonNullExpression */: + case 212 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13299,13 +13346,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 190 /* TypeAssertionExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 192 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13314,9 +13361,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -13335,15 +13382,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: - case 193 /* ArrowFunction */: - case 200 /* BinaryExpression */: - case 204 /* SpreadElement */: - case 208 /* AsExpression */: - case 206 /* OmittedExpression */: - case 303 /* CommaListExpression */: - case 302 /* PartiallyEmittedExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: + case 195 /* ArrowFunction */: + case 202 /* BinaryExpression */: + case 206 /* SpreadElement */: + case 210 /* AsExpression */: + case 208 /* OmittedExpression */: + case 306 /* CommaListExpression */: + case 305 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13351,18 +13398,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 /* TypeAssertionExpression */ - || kind === 208 /* AsExpression */; + return kind === 192 /* TypeAssertionExpression */ + || kind === 210 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 302 /* PartiallyEmittedExpression */; + return node.kind === 305 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 301 /* NotEmittedStatement */; + return node.kind === 304 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -13373,13 +13420,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return true; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13387,7 +13434,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; + return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13411,113 +13458,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */ + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */; + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 239 /* ModuleDeclaration */; + || kind === 242 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 /* NamedImports */ - || kind === 246 /* NamespaceImport */; + return kind === 250 /* NamedImports */ + || kind === 249 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; + return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 /* ArrowFunction */ - || kind === 182 /* BindingElement */ - || kind === 235 /* ClassDeclaration */ - || kind === 205 /* ClassExpression */ + return kind === 195 /* ArrowFunction */ + || kind === 184 /* BindingElement */ + || kind === 238 /* ClassDeclaration */ + || kind === 207 /* ClassExpression */ || kind === 155 /* Constructor */ - || kind === 238 /* EnumDeclaration */ - || kind === 273 /* EnumMember */ - || kind === 252 /* ExportSpecifier */ - || kind === 234 /* FunctionDeclaration */ - || kind === 192 /* FunctionExpression */ + || kind === 241 /* EnumDeclaration */ + || kind === 276 /* EnumMember */ + || kind === 255 /* ExportSpecifier */ + || kind === 237 /* FunctionDeclaration */ + || kind === 194 /* FunctionExpression */ || kind === 156 /* GetAccessor */ - || kind === 245 /* ImportClause */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 248 /* ImportSpecifier */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 262 /* JsxAttribute */ + || kind === 248 /* ImportClause */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 251 /* ImportSpecifier */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 265 /* JsxAttribute */ || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ - || kind === 239 /* ModuleDeclaration */ - || kind === 242 /* NamespaceExportDeclaration */ - || kind === 246 /* NamespaceImport */ + || kind === 242 /* ModuleDeclaration */ + || kind === 245 /* NamespaceExportDeclaration */ + || kind === 249 /* NamespaceImport */ || kind === 149 /* Parameter */ - || kind === 270 /* PropertyAssignment */ + || kind === 273 /* PropertyAssignment */ || kind === 152 /* PropertyDeclaration */ || kind === 151 /* PropertySignature */ || kind === 157 /* SetAccessor */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 237 /* TypeAliasDeclaration */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 240 /* TypeAliasDeclaration */ || kind === 148 /* TypeParameter */ - || kind === 232 /* VariableDeclaration */ - || kind === 298 /* JSDocTypedefTag */ - || kind === 292 /* JSDocCallbackTag */ - || kind === 299 /* JSDocPropertyTag */; + || kind === 235 /* VariableDeclaration */ + || kind === 301 /* JSDocTypedefTag */ + || kind === 295 /* JSDocCallbackTag */ + || kind === 302 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - 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 */; + return kind === 237 /* FunctionDeclaration */ + || kind === 256 /* MissingDeclaration */ + || kind === 238 /* ClassDeclaration */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 240 /* TypeAliasDeclaration */ + || kind === 241 /* EnumDeclaration */ + || kind === 242 /* ModuleDeclaration */ + || kind === 247 /* ImportDeclaration */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 253 /* ExportDeclaration */ + || kind === 252 /* ExportAssignment */ + || kind === 245 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - 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 === 301 /* NotEmittedStatement */ - || kind === 305 /* EndOfDeclarationMarker */ - || kind === 304 /* MergeDeclarationMarker */; + return kind === 227 /* BreakStatement */ + || kind === 226 /* ContinueStatement */ + || kind === 234 /* DebuggerStatement */ + || kind === 221 /* DoStatement */ + || kind === 219 /* ExpressionStatement */ + || kind === 218 /* EmptyStatement */ + || kind === 224 /* ForInStatement */ + || kind === 225 /* ForOfStatement */ + || kind === 223 /* ForStatement */ + || kind === 220 /* IfStatement */ + || kind === 231 /* LabeledStatement */ + || kind === 228 /* ReturnStatement */ + || kind === 230 /* SwitchStatement */ + || kind === 232 /* ThrowStatement */ + || kind === 233 /* TryStatement */ + || kind === 217 /* VariableStatement */ + || kind === 222 /* WhileStatement */ + || kind === 229 /* WithStatement */ + || kind === 304 /* NotEmittedStatement */ + || kind === 308 /* EndOfDeclarationMarker */ + || kind === 307 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 297 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -13544,10 +13591,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213 /* Block */) + if (node.kind !== 216 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { + if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { return false; } } @@ -13557,7 +13604,7 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 254 /* ExternalModuleReference */ + return kind === 257 /* ExternalModuleReference */ || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } @@ -13568,62 +13615,62 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 185 /* PropertyAccessExpression */; + || kind === 187 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 255 /* JsxElement */ - || kind === 265 /* JsxExpression */ - || kind === 256 /* JsxSelfClosingElement */ + return kind === 258 /* JsxElement */ + || kind === 268 /* JsxExpression */ + || kind === 259 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 259 /* JsxFragment */; + || kind === 262 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 /* JsxAttribute */ - || kind === 264 /* JsxSpreadAttribute */; + return kind === 265 /* JsxAttribute */ + || kind === 267 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 265 /* JsxExpression */; + || kind === 268 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 /* JsxOpeningElement */ - || kind === 256 /* JsxSelfClosingElement */; + return kind === 260 /* JsxOpeningElement */ + || kind === 259 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 /* CaseClause */ - || kind === 267 /* DefaultClause */; + return kind === 269 /* CaseClause */ + || kind === 270 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 299 /* LastJSDocNode */; + return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 302 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 /* 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 >= 289 /* FirstJSDocTagNode */ && node.kind <= 299 /* LastJSDocTagNode */; + return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 302 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -13666,22 +13713,22 @@ var ts; 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 */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: + case 179 /* MappedType */: + case 192 /* TypeAssertionExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 210 /* AsExpression */: + case 235 /* VariableDeclaration */: + case 237 /* FunctionDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 281 /* JSDocTypeExpression */: + case 284 /* JSDocNullableType */: + case 285 /* JSDocNonNullableType */: + case 286 /* JSDocOptionalType */: + case 287 /* JSDocFunctionType */: + case 288 /* JSDocVariadicType */: return true; } return false; @@ -13701,10 +13748,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -13716,7 +13763,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13753,7 +13800,7 @@ var ts; (function (ts) { /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; + return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -13894,6 +13941,13 @@ var ts; } /* @internal */ function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + /* @internal */ + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -13901,7 +13955,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; + } + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -14444,17 +14510,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.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; - } + function isDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; // Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. @@ -15007,7 +15071,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 274 /* SourceFile */) { + if (kind === 277 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -15071,14 +15135,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* 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 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -15103,20 +15167,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270 /* PropertyAssignment */: + case 273 /* 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 232 /* VariableDeclaration */: + case 235 /* 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 182 /* BindingElement */: + case 184 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15138,9 +15202,9 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15165,290 +15229,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172 /* InferType */: + case 174 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 179 /* ImportType */: + case 181 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: return visitNode(cbNode, node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177 /* MappedType */: + case 179 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return visitNode(cbNode, node.literal); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitNode(cbNode, node.name); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return visitNode(cbNode, node.label); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* 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 236 /* InterfaceDeclaration */: + case 239 /* 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 237 /* TypeAliasDeclaration */: + case 240 /* 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 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 278 /* JSDocTypeExpression */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 281 /* JSDocTypeExpression */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 286 /* JSDocOptionalType */: + case 288 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 282 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 281 /* JSDocNullableType */: - return visitNode(cbNode, node.type); - case 283 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 286 /* JSDocComment */: + case 289 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15457,17 +15519,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 278 /* JSDocTypeExpression */) { + node.typeExpression.kind === 281 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15475,18 +15537,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292 /* JSDocCallbackTag */: + case 295 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295 /* JSDocThisTag */: + case 298 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocSignature */: + case 291 /* 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 287 /* JSDocTypeLiteral */: + case 290 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15494,7 +15556,7 @@ var ts; } } return; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15708,7 +15770,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216 /* ExpressionStatement */); + var statement = createNode(219 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15825,13 +15887,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); // Should only be called once per node + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -15867,7 +15926,7 @@ 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(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16674,7 +16733,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 152 /* PropertyDeclaration */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return true; case 154 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -16691,8 +16750,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: return true; } } @@ -16701,42 +16760,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - 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 */: + case 237 /* FunctionDeclaration */: + case 217 /* VariableStatement */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 219 /* ExpressionStatement */: + case 232 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 230 /* SwitchStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 218 /* EmptyStatement */: + case 233 /* TryStatement */: + case 231 /* LabeledStatement */: + case 221 /* DoStatement */: + case 234 /* DebuggerStatement */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -16752,7 +16811,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232 /* VariableDeclaration */) { + if (node.kind !== 235 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16878,7 +16937,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -16940,7 +17004,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202 /* TemplateExpression */); + var template = createNode(204 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -16952,7 +17016,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211 /* TemplateSpan */); + var span = createNode(214 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -17018,10 +17082,9 @@ var ts; case 163 /* FunctionType */: case 164 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17035,14 +17098,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174 /* ThisType */); + var node = createNode(176 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279 /* JSDocAllType */); + var result = createNode(282 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, result); + return createPostfixType(286 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17050,7 +17113,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282 /* JSDocNonNullableType */); + var result = createNode(285 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17074,18 +17137,18 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(280 /* JSDocUnknownType */, pos); + var result = createNode(283 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(281 /* JSDocNullableType */, pos); + var result = createNode(284 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -17107,12 +17170,12 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, type); + return createPostfixType(286 /* JSDocOptionalType */, type); } return type; } @@ -17452,7 +17515,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177 /* MappedType */); + var node = createNode(179 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17474,13 +17537,26 @@ var ts; parseExpected(18 /* CloseBraceToken */); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24 /* DotDotDotToken */)) { + var node = createNode(170 /* RestType */, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 169 /* OptionalType */; + } + return type; + } function parseTupleType() { var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173 /* ParenthesizedType */); + var node = createNode(175 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); parseExpected(20 /* CloseParenToken */); @@ -17498,10 +17574,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178 /* LiteralType */); + var node = createNode(180 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17522,7 +17598,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(179 /* ImportType */); + var node = createNode(181 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17648,19 +17724,19 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); + type = createPostfixType(285 /* 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(281 /* JSDocNullableType */, type); + type = createPostfixType(284 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(176 /* IndexedAccessType */, type.pos); + var node = createNode(178 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); @@ -17679,21 +17755,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175 /* TypeOperator */); + var node = createNode(177 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172 /* InferType */); + var node = createNode(174 /* InferType */); parseExpected(126 /* InferKeyword */); var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); @@ -17726,10 +17802,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17813,7 +17889,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(171 /* ConditionalType */, type.pos); + var node = createNode(173 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -18006,7 +18082,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203 /* YieldExpression */); + var node = createNode(205 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -18028,11 +18104,11 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193 /* ArrowFunction */, asyncModifier.pos); + node = createNode(195 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193 /* ArrowFunction */, identifier.pos); + node = createNode(195 /* ArrowFunction */, identifier.pos); } var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; @@ -18230,7 +18306,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193 /* ArrowFunction */); + var node = createNodeWithJSDoc(195 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18294,7 +18370,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(201 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18374,39 +18450,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200 /* BinaryExpression */, left.pos); + var node = createNode(202 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208 /* AsExpression */, left.pos); + var node = createNode(210 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194 /* DeleteExpression */); + var node = createNode(196 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195 /* TypeOfExpression */); + var node = createNode(197 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196 /* VoidExpression */); + var node = createNode(198 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18422,7 +18498,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197 /* AwaitExpression */); + var node = createNode(199 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18466,7 +18542,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 192 /* 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 { @@ -18563,7 +18639,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18576,7 +18652,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18632,7 +18708,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(210 /* MetaProperty */, fullStart); + var node = createNode(212 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18707,7 +18783,7 @@ 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(185 /* PropertyAccessExpression */, expression.pos); + var node = createNode(187 /* 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); @@ -18716,8 +18792,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257 /* JsxOpeningElement */) { - var node = createNode(255 /* JsxElement */, opening.pos); + if (opening.kind === 260 /* JsxOpeningElement */) { + var node = createNode(258 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18726,15 +18802,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260 /* JsxOpeningFragment */) { - var node = createNode(259 /* JsxFragment */, opening.pos); + else if (opening.kind === 263 /* JsxOpeningFragment */) { + var node = createNode(262 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18749,7 +18825,7 @@ 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(200 /* BinaryExpression */, result.pos); + var badNode = createNode(202 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -18807,7 +18883,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263 /* JsxAttributes */); + var jsxAttributes = createNode(266 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18816,7 +18892,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18828,7 +18904,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(257 /* JsxOpeningElement */, fullStart); + node = createNode(260 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18840,7 +18916,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(256 /* JsxSelfClosingElement */, fullStart); + node = createNode(259 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18857,7 +18933,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18865,7 +18941,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265 /* JsxExpression */); + var node = createNode(268 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18887,7 +18963,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262 /* JsxAttribute */); + var node = createNode(265 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18902,7 +18978,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264 /* JsxSpreadAttribute */); + var node = createNode(267 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18910,7 +18986,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258 /* JsxClosingElement */); + var node = createNode(261 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18923,7 +18999,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261 /* JsxClosingFragment */); + var node = createNode(264 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18938,7 +19014,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190 /* TypeAssertionExpression */); + var node = createNode(192 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18949,7 +19025,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18957,14 +19033,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(211 /* 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(186 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(188 /* 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); @@ -18991,7 +19067,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -19015,7 +19091,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -19023,7 +19099,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19135,28 +19211,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204 /* SpreadElement */); + var node = createNode(206 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183 /* ArrayLiteralExpression */); + var node = createNode(185 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19168,7 +19244,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 272 /* SpreadAssignment */; + node.kind = 275 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19195,7 +19271,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 = 271 /* ShorthandPropertyAssignment */; + node.kind = 274 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -19203,14 +19279,14 @@ var ts; } } else { - node.kind = 270 /* PropertyAssignment */; + node.kind = 273 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184 /* ObjectLiteralExpression */); + var node = createNode(186 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19229,7 +19305,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(192 /* FunctionExpression */); + var node = createNodeWithJSDoc(194 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19254,7 +19330,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(210 /* MetaProperty */, fullStart); + var node_2 = createNode(212 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19271,7 +19347,7 @@ var ts; } break; } - var node = createNode(188 /* NewExpression */, fullStart); + var node = createNode(190 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19281,7 +19357,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213 /* Block */); + var node = createNode(216 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19314,12 +19390,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215 /* EmptyStatement */); + var node = createNode(218 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(217 /* IfStatement */); + var node = createNode(220 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19329,7 +19405,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218 /* DoStatement */); + var node = createNode(221 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19344,7 +19420,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219 /* WhileStatement */); + var node = createNode(222 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19368,7 +19444,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(222 /* ForOfStatement */, pos); + var forOfStatement = createNode(225 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19376,14 +19452,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(221 /* ForInStatement */, pos); + var forInStatement = createNode(224 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220 /* ForStatement */, pos); + var forStatement = createNode(223 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19401,7 +19477,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19409,7 +19485,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225 /* ReturnStatement */); + var node = createNode(228 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19418,7 +19494,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226 /* WithStatement */); + var node = createNode(229 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19427,7 +19503,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266 /* CaseClause */); + var node = createNode(269 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19435,7 +19511,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267 /* DefaultClause */); + var node = createNode(270 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19445,12 +19521,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227 /* SwitchStatement */); + var node = createNode(230 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(241 /* CaseBlock */); + var caseBlock = createNode(244 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19465,7 +19541,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(229 /* ThrowStatement */); + var node = createNode(232 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19473,7 +19549,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(230 /* TryStatement */); + var node = createNode(233 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19486,7 +19562,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269 /* CatchClause */); + var result = createNode(272 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19500,7 +19576,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231 /* DebuggerStatement */); + var node = createNode(234 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19512,12 +19588,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 228 /* LabeledStatement */; + node.kind = 231 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216 /* ExpressionStatement */; + node.kind = 219 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19684,16 +19760,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19703,9 +19779,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(223 /* ContinueStatement */); + return parseBreakOrContinueStatement(226 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(224 /* BreakStatement */); + return parseBreakOrContinueStatement(227 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19802,7 +19878,7 @@ 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(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -19825,16 +19901,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(206 /* OmittedExpression */); + return createNode(208 /* OmittedExpression */); } - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19850,14 +19926,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180 /* ObjectBindingPattern */); + var node = createNode(182 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181 /* ArrayBindingPattern */); + var node = createNode(183 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19879,7 +19955,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232 /* VariableDeclaration */); + var node = createNode(235 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19892,7 +19968,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233 /* VariableDeclarationList */); + var node = createNode(236 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19930,13 +20006,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 214 /* VariableStatement */; + node.kind = 217 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234 /* FunctionDeclaration */; + node.kind = 237 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -20118,7 +20194,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(212 /* SemicolonClassElement */); + var result = createNode(215 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -20155,10 +20231,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -20201,14 +20277,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(268 /* HeritageClause */); + var node = createNode(271 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -20225,7 +20301,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236 /* InterfaceDeclaration */; + node.kind = 239 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20234,7 +20310,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237 /* TypeAliasDeclaration */; + node.kind = 240 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20248,13 +20324,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(273 /* EnumMember */); + var node = createNodeWithJSDoc(276 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238 /* EnumDeclaration */; + node.kind = 241 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20267,7 +20343,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240 /* ModuleBlock */); + var node = createNode(243 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20278,7 +20354,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* 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 */; @@ -20290,7 +20366,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -20336,7 +20412,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 242 /* NamespaceExportDeclaration */; + node.kind = 245 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20354,7 +20430,7 @@ var ts; } } // Import statement - node.kind = 244 /* ImportDeclaration */; + node.kind = 247 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20369,7 +20445,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243 /* ImportEqualsDeclaration */; + node.kind = 246 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20383,7 +20459,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(245 /* ImportClause */, fullStart); + var importClause = createNode(248 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20393,7 +20469,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); } return finishNode(importClause); } @@ -20403,7 +20479,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(254 /* ExternalModuleReference */); + var node = createNode(257 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20426,7 +20502,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(246 /* NamespaceImport */); + var namespaceImport = createNode(249 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20441,14 +20517,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252 /* ExportSpecifier */); + return parseImportOrExportSpecifier(255 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248 /* ImportSpecifier */); + return parseImportOrExportSpecifier(251 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20473,19 +20549,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250 /* ExportDeclaration */; + node.kind = 253 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(254 /* 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. @@ -20498,7 +20574,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249 /* ExportAssignment */; + node.kind = 252 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20518,10 +20594,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ - || node.kind === 244 /* ImportDeclaration */ - || node.kind === 249 /* ExportAssignment */ - || node.kind === 250 /* ExportDeclaration */ + || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ + || node.kind === 247 /* ImportDeclaration */ + || node.kind === 252 /* ExportAssignment */ + || node.kind === 253 /* ExportDeclaration */ ? node : undefined; } @@ -20584,7 +20660,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20644,17 +20720,16 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var state = 1 /* SawAsterisk */; @@ -20740,9 +20815,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -20754,7 +20828,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286 /* JSDocComment */, start); + var result = createNode(289 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20871,6 +20945,16 @@ var ts; indent += whitespace.length; } break; + case 17 /* OpenBraceToken */: + state = 2 /* SavingComments */; + if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token @@ -20892,7 +20976,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289 /* JSDocTag */, atToken.pos); + var result = createNode(292 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20952,8 +21036,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(299 /* JSDocPropertyTag */, atToken.pos) : - createNode(293 /* JSDocParameterTag */, atToken.pos); + createNode(302 /* JSDocPropertyTag */, atToken.pos) : + createNode(296 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -20973,18 +21057,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281 /* 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 === 293 /* JSDocParameterTag */ || child.kind === 299 /* JSDocPropertyTag */) { + if (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -20995,27 +21079,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocReturnTag */, atToken.pos); + var result = createNode(297 /* 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 === 296 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296 /* JSDocTypeTag */, atToken.pos); + var result = createNode(299 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -21023,7 +21107,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -21035,7 +21119,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(185 /* PropertyAccessExpression */, node.pos); + var prop = createNode(187 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -21043,13 +21127,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291 /* JSDocClassTag */, atToken.pos); + var tag = createNode(294 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295 /* JSDocThisTag */, atToken.pos); + var tag = createNode(298 /* JSDocThisTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); @@ -21059,7 +21143,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(301 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21075,9 +21159,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 296 /* JSDocTypeTag */) { + if (child.kind === 299 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21109,7 +21193,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21123,7 +21207,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21132,7 +21216,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288 /* JSDocSignature */, start); + var jsdocSignature = createNode(291 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -21140,7 +21224,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 294 /* JSDocReturnTag */) { + if (tag && tag.kind === 297 /* JSDocReturnTag */) { return tag; } } @@ -21185,9 +21269,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 /* JSDocParameterTag */ && + if (child && (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -21261,7 +21345,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(300 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22065,6 +22149,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -23234,7 +23319,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 !== 270 /* PropertyAssignment */) { + if (element.kind !== 273 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -23311,13 +23396,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198 /* PrefixUnaryExpression */: + case 200 /* 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 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -23334,7 +23419,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25422,24 +25507,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 238 /* EnumDeclaration */: - if (ts.isConst(node)) { + case 241 /* EnumDeclaration */: + if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 240 /* ModuleBlock */: { + case 243 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -25461,7 +25546,7 @@ var ts; }); return state_1; } - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -25620,7 +25705,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 === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -25645,32 +25730,32 @@ var ts; return "__constructor" /* Constructor */; case 163 /* FunctionType */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return "__call" /* Call */; case 164 /* ConstructorType */: case 159 /* ConstructSignature */: return "__new" /* New */; case 160 /* IndexSignature */: return "__index" /* Index */; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); 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 === 284 /* 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 === 287 /* 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; @@ -25764,7 +25849,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 === 249 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 252 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -25789,7 +25874,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -25856,7 +25941,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 !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -25901,7 +25986,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -25950,8 +26035,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -25983,77 +26068,78 @@ var ts; return; } switch (node.kind) { - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: bindWhileStatement(node); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: bindDoStatement(node); break; - case 220 /* ForStatement */: + case 223 /* ForStatement */: bindForStatement(node); break; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: bindIfStatement(node); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: bindTryStatement(node); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: bindSwitchStatement(node); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: bindCaseBlock(node); break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: bindCaseClause(node); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: bindLabeledStatement(node); break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: bindCallExpressionFlow(node); break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 274 /* SourceFile */: + case 277 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213 /* Block */: - case 240 /* ModuleBlock */: + } + case 216 /* Block */: + case 243 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -26066,15 +26152,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return hasNarrowableArgument(expr); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -26083,7 +26169,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -26094,7 +26180,7 @@ var ts; } } } - if (expr.expression.kind === 185 /* PropertyAccessExpression */ && + if (expr.expression.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -26127,9 +26213,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -26207,33 +26293,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return parent.expression === node; - case 220 /* ForStatement */: - case 201 /* ConditionalExpression */: + case 223 /* ForStatement */: + case 203 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191 /* ParenthesizedExpression */) { + if (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 /* ParenthesizedExpression */ || - node.parent.kind === 198 /* PrefixUnaryExpression */ && + while (node.parent.kind === 193 /* ParenthesizedExpression */ || + node.parent.kind === 200 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -26275,7 +26361,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -26309,13 +26395,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222 /* ForOfStatement */) { + if (node.kind === 225 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233 /* VariableDeclarationList */) { + if (node.initializer.kind !== 236 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -26337,7 +26423,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225 /* ReturnStatement */) { + if (node.kind === 228 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -26357,7 +26443,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -26453,7 +26539,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* 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; @@ -26521,14 +26607,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -26539,10 +26625,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183 /* ArrayLiteralExpression */) { + else if (node.kind === 185 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204 /* SpreadElement */) { + if (e.kind === 206 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -26550,16 +26636,16 @@ var ts; } } } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270 /* PropertyAssignment */) { + if (p.kind === 273 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271 /* ShorthandPropertyAssignment */) { + else if (p.kind === 274 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272 /* SpreadAssignment */) { + else if (p.kind === 275 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -26615,7 +26701,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26626,7 +26712,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -26673,10 +26759,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 === 191 /* ParenthesizedExpression */) { + while (expr.kind === 193 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { + if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -26684,7 +26770,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26693,21 +26779,21 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 266 /* JsxAttributes */: return 1 /* IsContainer */; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 179 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -26715,32 +26801,32 @@ var ts; } // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: - case 284 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: case 163 /* FunctionType */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 269 /* CatchClause */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 241 /* CaseBlock */: + case 272 /* CatchClause */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 244 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 213 /* Block */: + case 216 /* 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 @@ -26773,20 +26859,20 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 184 /* ObjectLiteralExpression */: - case 236 /* InterfaceDeclaration */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 186 /* ObjectLiteralExpression */: + case 239 /* InterfaceDeclaration */: + case 266 /* 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 @@ -26797,21 +26883,21 @@ var ts; case 164 /* ConstructorType */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 288 /* JSDocSignature */: + case 291 /* 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 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 287 /* JSDocFunctionType */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 240 /* TypeAliasDeclaration */: + case 179 /* 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 @@ -26832,11 +26918,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { + var body = node.kind === 277 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { + if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { return true; } } @@ -26920,7 +27006,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 === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -26932,7 +27018,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 === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -26964,10 +27050,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -27108,8 +27194,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 274 /* SourceFile */ && - blockScopeContainer.kind !== 239 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 277 /* SourceFile */ && + blockScopeContainer.kind !== 242 /* 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. @@ -27205,7 +27291,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1 /* EndOfFileToken */) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -27263,11 +27353,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -27275,7 +27365,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -27303,19 +27393,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return checkStrictModeCatchClause(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkStrictModeWithStatement(node); - case 174 /* ThisType */: + case 176 /* ThisType */: seenThisKeyword = true; return; case 161 /* TypePredicate */: @@ -27324,18 +27414,18 @@ var ts; return bindTypeParameter(node); case 149 /* Parameter */: return bindParameter(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); case 158 /* CallSignature */: case 159 /* ConstructSignature */: @@ -27348,7 +27438,7 @@ var ts; // 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -27357,83 +27447,83 @@ var ts; case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 177 /* MappedType */: + case 290 /* JSDocTypeLiteral */: + case 179 /* MappedType */: return bindAnonymousTypeWorker(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return bindFunctionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return bindJsxAttributes(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return bindImportClause(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return bindExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return bindExportAssignment(node); - case 274 /* SourceFile */: + case 277 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213 /* Block */: + case 216 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 293 /* JSDocParameterTag */: - if (node.parent.kind === 288 /* JSDocSignature */) { + case 296 /* JSDocParameterTag */: + if (node.parent.kind === 291 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { break; } // falls through - case 299 /* JSDocPropertyTag */: + case 302 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -27465,7 +27555,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 /* 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 @@ -27479,7 +27569,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274 /* SourceFile */) { + if (node.parent.kind !== 277 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -27564,8 +27654,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 */) { @@ -27592,7 +27682,7 @@ var ts; 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 274 /* SourceFile */: + case 277 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -27604,7 +27694,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -27661,9 +27751,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + : propertyAccess.parent.parent.kind === 277 /* SourceFile */; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; @@ -27757,7 +27847,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -27790,7 +27880,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); } @@ -27820,7 +27910,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { + if (node.kind === 296 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -27897,7 +27987,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 172 /* InferType */) { + else if (node.parent.kind === 174 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -27925,13 +28015,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || // report error on class declarations - node.kind === 235 /* ClassDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -27988,43 +28078,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); @@ -28035,11 +28125,11 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -28091,12 +28181,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* 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 === 183 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -28145,8 +28235,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 === 208 /* AsExpression */ - || expressionKind === 190 /* TypeAssertionExpression */) { + if (expressionKind === 210 /* AsExpression */ + || expressionKind === 192 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -28523,13 +28613,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -28540,25 +28630,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 209 /* NonNullExpression */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 211 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: case 10 /* JsxText */: - case 258 /* JsxClosingElement */: - case 259 /* JsxFragment */: - case 260 /* JsxOpeningFragment */: - case 261 /* JsxClosingFragment */: - case 262 /* JsxAttribute */: - case 263 /* JsxAttributes */: - case 264 /* JsxSpreadAttribute */: - case 265 /* JsxExpression */: + case 261 /* JsxClosingElement */: + case 262 /* JsxFragment */: + case 263 /* JsxOpeningFragment */: + case 264 /* JsxClosingFragment */: + case 265 /* JsxAttribute */: + case 266 /* JsxAttributes */: + case 267 /* JsxSpreadAttribute */: + case 268 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -28566,11 +28656,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: - case 271 /* ShorthandPropertyAssignment */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 274 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -28584,14 +28674,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 222 /* ForOfStatement */: + case 225 /* 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 203 /* YieldExpression */: + case 205 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -28618,19 +28708,21 @@ var ts; 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 */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 174 /* InferType */: + case 175 /* ParenthesizedType */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: + case 245 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; @@ -28652,10 +28744,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -28667,18 +28759,18 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; @@ -28688,7 +28780,7 @@ var ts; // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -28706,8 +28798,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 183 /* ArrayLiteralExpression */: - case 188 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: + case 190 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -28715,26 +28807,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -28750,27 +28842,27 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 183 /* ArrayLiteralExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return 942011713 /* ClassExcludes */; case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; @@ -28792,24 +28884,24 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 269 /* CatchClause */: + case 272 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: - case 191 /* ParenthesizedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: + case 193 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -29098,6 +29190,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -29171,7 +29264,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -29269,6 +29361,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -29327,7 +29420,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -29384,6 +29477,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; /** @@ -29597,143 +29691,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - 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) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - 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)); // 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)); // TODO: GH#18217 - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896 /* TypeParameters */, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - 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)] : []; // 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)); })); // TODO: GH#18217 - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - 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)); // TODO: GH#18217 - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -29771,6 +29728,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -29896,22 +29878,57 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { - var message_2 = target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */ + var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); + var isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 /* LessThan */ ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -29986,7 +30003,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -30044,17 +30061,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 182 /* BindingElement */) { + if (declaration.kind === 184 /* 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, 182 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 184 /* 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, 232 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235 /* VariableDeclaration */), usage); } - else if (declaration.kind === 232 /* VariableDeclaration */) { + else if (declaration.kind === 235 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -30072,12 +30089,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 === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* 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 === 249 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 252 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -30085,9 +30102,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214 /* VariableStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 217 /* VariableStatement */: + case 223 /* ForStatement */: + case 225 /* 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)) { @@ -30159,7 +30176,7 @@ 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 !== 286 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -30179,7 +30196,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171 /* ConditionalType */) { + else if (location.kind === 173 /* 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; @@ -30193,14 +30210,14 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 277 /* 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 */)) { @@ -30224,7 +30241,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { break; } } @@ -30238,7 +30255,7 @@ var ts; } } break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -30261,9 +30278,9 @@ var ts; } } break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -30279,7 +30296,7 @@ var ts; } break loop; } - if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -30287,7 +30304,7 @@ var ts; } } break; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* 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; @@ -30309,7 +30326,7 @@ var ts; // case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* 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); @@ -30322,14 +30339,14 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -30364,8 +30381,8 @@ var ts; location = location.parent; } break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -30384,7 +30401,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -30458,7 +30475,7 @@ 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 === 242 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 245 /* 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 } } @@ -30467,12 +30484,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 239 /* ModuleDeclaration */: // For `namespace N { N; }` + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -30540,9 +30557,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -30606,18 +30623,26 @@ 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 === 238 /* EnumDeclaration */) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32 /* Class */) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256 /* RegularEnum */) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -30630,13 +30655,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 245 /* ImportClause */: + case 248 /* ImportClause */: return node.parent; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return node.parent.parent; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -30646,7 +30671,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -30834,20 +30859,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 249 /* ExportAssignment */: - case 200 /* BinaryExpression */: + case 252 /* ExportAssignment */: + case 202 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -30908,11 +30933,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 252 /* ExportSpecifier */) { + else if (node.kind === 255 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -30940,7 +30965,7 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -30964,7 +30989,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -31129,10 +31154,19 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages( - /*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)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages( + /*details*/ undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : 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)) + : undefined; 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)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -31158,7 +31192,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -31391,6 +31425,12 @@ var ts; var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -31409,25 +31449,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -31443,12 +31477,12 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -31545,7 +31579,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, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -31657,10 +31691,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -31713,8 +31747,8 @@ var ts; // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || - entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || + entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -31796,64 +31830,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; // TODO: GH#18217 + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -31861,6 +31864,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -31978,7 +31983,7 @@ var ts; 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 & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -32047,7 +32052,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 === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -32085,7 +32090,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; + return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -32133,8 +32138,15 @@ var ts; } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -32348,7 +32360,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 === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -32402,7 +32414,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -32410,7 +32422,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); 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 isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -32419,7 +32431,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; + var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -32429,7 +32442,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 === 182 /* BindingElement */) { + if (clone.kind === 184 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -32513,17 +32526,49 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + 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, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= 16777216 /* InInitialEntityName */; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216 /* InInitialEntityName */; var isTypeOf = meaning === 67216319 /* Value */; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -32697,8 +32742,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 !== 173 /* ParenthesizedType */; }); - if (node.kind === 237 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); + if (node.kind === 240 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -32706,11 +32751,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 /* ModuleBlock */ && + node.parent.kind === 243 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -32730,42 +32775,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 - var file = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); - if (!file || !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); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205 /* ClassExpression */: - return "(Anonymous class)"; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - return "(Anonymous function)"; + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + context.encounteredError = true; + } + return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -32790,27 +32815,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* 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 182 /* BindingElement */: + case 184 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 232 /* VariableDeclaration */: + case 235 /* 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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 234 /* FunctionDeclaration */: - case 238 /* EnumDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 241 /* EnumDeclaration */: + case 246 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -32818,7 +32843,7 @@ 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 !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -32840,31 +32865,31 @@ var ts; case 158 /* CallSignature */: case 160 /* IndexSignature */: case 149 /* Parameter */: - case 240 /* ModuleBlock */: + case 243 /* 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 */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 175 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: return false; // Type parameters are always visible case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 274 /* SourceFile */: - case 242 /* NamespaceExportDeclaration */: + case 277 /* SourceFile */: + case 245 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return false; default: return false; @@ -32873,10 +32898,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 252 /* ExportSpecifier */) { + else if (node.parent.kind === 255 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -32972,12 +32997,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232 /* VariableDeclaration */: - case 233 /* VariableDeclarationList */: - case 248 /* ImportSpecifier */: - case 247 /* NamedImports */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 235 /* VariableDeclaration */: + case 236 /* VariableDeclarationList */: + case 251 /* ImportSpecifier */: + case 250 /* NamedImports */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: return false; default: return true; @@ -33054,7 +33079,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180 /* ObjectBindingPattern */) { + if (pattern.kind === 182 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -33124,22 +33149,27 @@ var ts; // 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(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); + // If the parent is a tuple type, the rest element has an array type with a union of the + // remaining tuple element types. Otherwise, the rest element has an array type with same + // element type as the parent type. + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -33150,7 +33180,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2 /* Subtype */) : type; } @@ -33167,7 +33197,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -33177,11 +33207,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 === 221 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* 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, @@ -33200,7 +33230,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 /* 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 @@ -33272,20 +33302,20 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : - declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : 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 === 155 /* Constructor */ || - thisContainer.kind === 234 /* FunctionDeclaration */ || - (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 /* FunctionDeclaration */ || + (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -33306,7 +33336,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { // If we don't have an explicit JSDoc type, get the type from the expression. var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 /* Anonymous */ && @@ -33388,7 +33418,7 @@ var ts; // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -33433,12 +33463,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { 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. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -33455,7 +33486,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 /* ObjectBindingPattern */ + return pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -33524,7 +33555,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 === 249 /* ExportAssignment */) { + if (declaration.kind === 252 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -33728,8 +33759,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 202 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 187 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 202 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -33866,35 +33897,35 @@ var ts; return undefined; } switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 153 /* MethodSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 177 /* MappedType */: - case 171 /* ConditionalType */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 179 /* MappedType */: + case 173 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177 /* MappedType */) { + if (node.kind === 179 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171 /* ConditionalType */) { + else if (node.kind === 173 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && + (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -33902,7 +33933,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, 236 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -33911,9 +33942,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 235 /* ClassDeclaration */ || - node.kind === 205 /* ClassExpression */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || + node.kind === 207 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -33947,15 +33978,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - // Prefer an @augments tag because it may have type parameters. - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -33978,7 +34001,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -34011,7 +34034,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { if (type.symbol.flags & 32 /* Class */) { @@ -34074,7 +34097,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; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -34099,7 +34122,7 @@ var ts; 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 === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -34135,7 +34158,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */) { + if (declaration.kind === 239 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -34193,7 +34216,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -34220,7 +34243,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 200 /* BinaryExpression */) { + else if (expr.kind === 202 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -34234,12 +34257,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* 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 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -34253,7 +34276,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -34280,7 +34303,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 @@ -34370,7 +34393,7 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 178 /* LiteralType */: + case 180 /* LiteralType */: return true; case 167 /* ArrayType */: return isThislessType(node.elementType); @@ -34750,6 +34773,28 @@ var ts; return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 /* RestParameter */ : + i >= minLength_1 ? 4096 /* OptionalParameter */ : 0; + var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); @@ -34927,6 +34972,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); @@ -34935,6 +34981,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); @@ -35093,7 +35140,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 175 /* TypeOperator */ && + return constraintDeclaration.kind === 177 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -35213,6 +35260,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144 /* Union */)) { @@ -35670,10 +35728,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 === 283 /* JSDocOptionalType */ + node.type && node.type.kind === 286 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -35692,7 +35750,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -35707,7 +35765,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -35802,7 +35860,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178 /* LiteralType */) { + if (type && type.kind === 180 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -35850,9 +35908,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 8192 /* RestParameter */); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { // Replace the last parameter with a rest parameter. parameters.pop(); @@ -35958,9 +36015,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -36003,16 +36060,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1 /* Number */) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -36114,32 +36168,40 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - // When an 'infer T' declaration is immediately contained in a type reference node - // (such as 'Foo'), T's constraint is inferred from the constraint of the - // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are - // present, we form an intersection of the inferred constraint types. - if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - // Type parameter constraints can reference other type parameters so - // constraints need to be instantiated. If instantiation produces the - // type parameter itself, we discard that inference. For example, in - // type Foo = [T, U]; - // type Bar = T extends Foo ? Foo : T; - // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174 /* InferType */) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162 /* TypeReference */) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + // When an 'infer T' declaration is immediately contained in a rest parameter + // declaration, we infer an 'unknown[]' constraint. + else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -36234,7 +36296,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 !== 290 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 293 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -36293,7 +36355,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -36386,9 +36448,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -36500,9 +36562,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return declaration; } } @@ -36623,18 +36685,26 @@ var ts; // // Note that the generic type created by this function has no symbol associated with it. The same // is true for each of the synthesized type parameters. - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536 /* TypeParameter */); - typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + if (i < maxLength) { + var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4 /* Property */, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; @@ -36652,21 +36722,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -37060,7 +37156,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -37125,7 +37221,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -37145,6 +37241,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { @@ -37155,7 +37257,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* 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))) { @@ -37172,14 +37274,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* 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)); } @@ -37285,7 +37395,7 @@ 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 === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -37425,7 +37535,7 @@ var ts; return true; } while (node) { - if (node.kind === 171 /* ConditionalType */) { + if (node.kind === 173 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -37523,7 +37633,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } 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); + var errorMessage = 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_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -37729,7 +37842,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -37748,8 +37861,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return anyType; case 142 /* UnknownKeyword */: return unknownType; @@ -37771,16 +37884,16 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 162 /* TypeReference */: return getTypeFromTypeReference(node); case 161 /* TypePredicate */: return booleanType; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); @@ -37788,38 +37901,41 @@ var ts; return getTypeFromArrayTypeNode(node); case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return getTypeFromOptionalTypeNode(node); + case 171 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 173 /* ParenthesizedType */: - case 282 /* JSDocNonNullableType */: - case 278 /* JSDocTypeExpression */: + case 175 /* ParenthesizedType */: + case 170 /* RestType */: + case 285 /* JSDocNonNullableType */: + case 281 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 172 /* InferType */: + case 174 /* InferType */: return getTypeFromInferTypeNode(node); - case 179 /* ImportType */: + case 181 /* 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 @@ -37968,7 +38084,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | (ts.getCheckFlags(symbol) & 1024 /* Late */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (1024 /* Late */ | 4096 /* OptionalParameter */ | 8192 /* RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -37979,11 +38095,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -38048,14 +38159,14 @@ 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 === 213 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -38193,32 +38304,32 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive); - case 262 /* JsxAttribute */: { + case 265 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265 /* JsxExpression */: { + case 268 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -38235,7 +38346,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* 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); @@ -38245,7 +38356,7 @@ var ts; } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 213 /* Block */ ? false : isContextSensitive(body); + return body.kind === 216 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -38315,8 +38426,206 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268 /* JsxExpression */: + case 193 /* ParenthesizedExpression */: + return elaborateError(node.expression, source, target); + case 202 /* BinaryExpression */: + switch (node.operatorToken.kind) { + case 58 /* EqualsToken */: + case 26 /* CommaToken */: + return elaborateError(node.right, source, target); + } + break; + case 186 /* ObjectLiteralExpression */: + return elaborateObjectLiteral(node, source, target); + case 185 /* ArrayLiteralExpression */: + return elaborateArrayLiteral(node, source, target); + case 266 /* JsxAttributes */: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator, source, target) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + var resultObj = {}; + // Use the expression type, if available + var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + getIndexInfoOfType(target, 0 /* String */) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3 /*break*/, 3]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2 /*return*/]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3 /*break*/, 4]; + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3 /*break*/, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3 /*break*/, 3]; + nameType = getLiteralType(i); + return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3 /*break*/, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 32768 /* Never */)) { + return [3 /*break*/, 7]; + } + _b = prop.kind; + switch (_b) { + case 157 /* SetAccessor */: return [3 /*break*/, 2]; + case 156 /* GetAccessor */: return [3 /*break*/, 2]; + case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + } + return [3 /*break*/, 6]; + case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3 /*break*/, 7]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3 /*break*/, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** * This is *not* a bi-directional relationship. @@ -38337,13 +38646,20 @@ var ts; if (source === target) { return -1 /* True */; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0 /* False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0 /* False */; + } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; @@ -38364,14 +38680,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -38390,7 +38703,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0 /* False */; } @@ -38465,30 +38778,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - // If both have rest parameters, get the max and add 1 to - // compensate for the rest parameter. - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - // Return the count for whichever signature doesn't have rest parameters. - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -38509,11 +38798,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { + return relation === 1 /* Succeeded */; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, false); + enumRelation.set(id, 3 /* FailedAndReported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -38524,13 +38813,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); + enumRelation.set(id, 3 /* FailedAndReported */); + } + else { + enumRelation.set(id, 2 /* Failed */); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1 /* Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -38621,7 +38913,7 @@ var ts; * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -38651,12 +38943,16 @@ var ts; var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); // Cause the error to appear with the error that triggered it + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); // Cause the error to appear with the error that triggered it } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); // TODO: GH#18217 + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { @@ -38738,6 +39034,22 @@ var ts; if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); + if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + target = nullStrippedTarget; + } + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; @@ -38989,11 +39301,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } return 0 /* False */; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072 /* Object */) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4 /* Reference */) { + return source.target === target.target; + } + if (overlapObjFlags & 16 /* Anonymous */) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { var match; @@ -39125,9 +39455,8 @@ var ts; var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { - // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported - // failure and continue computing the relation such that errors get reported. - relation.set(id, 3 /* FailedAndReported */); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -39414,7 +39743,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -39437,6 +39766,33 @@ var ts; } } var result = -1 /* True */; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0 /* False */; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0 /* False */; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0 /* False */; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -39958,20 +40314,26 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); // A source signature matches a target signature if the two signatures have the same number of required, // optional, and rest parameters. - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } // A source signature partially matches a target signature if the target signature has no fewer required // parameters and no more overall parameters than the source signature (where a signature with a rest // parameter is always considered to have more overall parameters than one without). - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -40013,10 +40375,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0 /* False */; @@ -40036,9 +40398,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -40088,7 +40447,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); @@ -40135,6 +40499,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -40194,7 +40564,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -40407,7 +40777,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -40417,23 +40787,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* 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 177 /* MappedType */: + case 179 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -40450,24 +40820,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -40606,10 +40974,14 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - // Two tuple types with different arity are definitely unrelated. + // Two tuple types with incompatible arities are definitely unrelated. // Two object types that each have a property that is unmatched in the other are definitely unrelated. - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) && !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false); } function getTypeFromInference(inference) { @@ -40892,12 +41264,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -41012,17 +41405,14 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + // If we have contravariant inferences we find the best common subtype and treat + // that as a single covariant candidate. + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { 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 & 32768 /* Never */ && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - // We only have contravariant inferences, infer the best common subtype of those - inferredType = getContravariantInference(inference); } else if (context.flags & 2 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -41099,13 +41489,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 185 /* PropertyAccessExpression */) { + if (node.kind === 187 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182 /* BindingElement */) { + if (node.kind === 184 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -41114,7 +41504,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180 /* ObjectBindingPattern */) { + if (parent.kind === 182 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: @@ -41137,26 +41527,26 @@ var ts; switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && + (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 185 /* PropertyAccessExpression */: - return target.kind === 185 /* PropertyAccessExpression */ && + case 187 /* PropertyAccessExpression */: + return target.kind === 187 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182 /* BindingElement */: - if (target.kind !== 185 /* PropertyAccessExpression */) + case 184 /* BindingElement */: + if (target.kind !== 187 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232 /* VariableDeclaration */) { + if (source.parent.parent.kind === 235 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -41164,7 +41554,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185 /* PropertyAccessExpression */) { + while (source.kind === 187 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -41177,7 +41567,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 === 185 /* PropertyAccessExpression */ && + return target.kind === 187 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -41185,7 +41575,7 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185 /* PropertyAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -41229,7 +41619,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -41355,7 +41745,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; } @@ -41363,15 +41753,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -41388,21 +41778,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return stringType; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return undefinedType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -41410,7 +41800,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 /* ObjectBindingPattern */ ? + var type = pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -41428,35 +41818,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221 /* ForInStatement */) { + if (node.parent.parent.kind === 224 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.parent.kind === 225 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 /* VariableDeclaration */ ? + return node.kind === 235 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? + return node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 /* VariableDeclaration */ && node.initializer && + return node.kind === 235 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && + node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -41468,13 +41858,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - 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 ? + return parent.kind === 193 /* ParenthesizedExpression */ || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -41637,11 +42027,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - 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 */ && + var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 200 /* BinaryExpression */ && + parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -41689,7 +42079,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 === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -41760,7 +42150,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 !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 187 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -41816,7 +42206,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 /* CallExpression */ ? + var expr = node.kind === 189 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -41824,7 +42214,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -41989,7 +42379,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 /* PropertyAccessExpression */ && + return expr.kind === 187 /* PropertyAccessExpression */ && computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -42040,10 +42430,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 === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -42258,7 +42648,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -42278,15 +42668,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -42322,8 +42712,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 /* ModuleBlock */ || - node.kind === 274 /* SourceFile */ || + node.kind === 243 /* ModuleBlock */ || + node.kind === 277 /* SourceFile */ || node.kind === 152 /* PropertyDeclaration */; }); } @@ -42369,10 +42759,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - 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; + return parent.kind === 187 /* PropertyAccessExpression */ || + parent.kind === 189 /* CallExpression */ && parent.expression === node || + parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); @@ -42406,7 +42796,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 */)) { @@ -42427,7 +42817,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 === 235 /* ClassDeclaration */ + if (declaration.kind === 238 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -42439,12 +42829,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205 /* ClassExpression */) { + else if (declaration.kind === 207 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 274 /* SourceFile */) { + while (container.kind !== 277 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; @@ -42494,23 +42884,23 @@ var ts; 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); + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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 === 192 /* FunctionExpression */ || - flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 /* FunctionExpression */ || + flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // 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 || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || 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 || + isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || + node.parent.kind === 211 /* NonNullExpression */ || + declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -42541,7 +42931,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -42566,8 +42956,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 === 220 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && + if (container.kind === 223 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -42581,7 +42971,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 191 /* ParenthesizedExpression */) { + while (current.parent.kind === 193 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -42589,7 +42979,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -42647,7 +43037,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); // If a containing class does not have extends clause or the class extends null // skip checking whether super statement is called before "this" accessing. if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -42674,17 +43064,17 @@ var ts; 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 === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 238 /* EnumDeclaration */: + case 241 /* 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; @@ -42722,8 +43112,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 === 192 /* FunctionExpression */ && - container.parent.kind === 200 /* BinaryExpression */ && + if (container.kind === 194 /* FunctionExpression */ && + container.parent.kind === 202 /* 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 @@ -42754,7 +43144,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -42771,12 +43161,12 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 /* 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 === 193 /* ArrowFunction */) { + while (container && container.kind === 195 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -42796,7 +43186,7 @@ var ts; 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 === 184 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -42884,7 +43274,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184 /* ObjectLiteralExpression */) { + if (container.parent.kind === 186 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -42896,7 +43286,7 @@ var ts; } // at this point the only legal case for parent is ClassLikeDeclaration var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -42928,7 +43318,7 @@ 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 === 184 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 154 /* MethodDeclaration */ || container.kind === 153 /* MethodSignature */ || @@ -42952,8 +43342,8 @@ var ts; function getContainingObjectLiteral(func) { 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 : + func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -42965,7 +43355,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193 /* ArrowFunction */) { + if (func.kind === 195 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -42992,7 +43382,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270 /* PropertyAssignment */) { + if (literal.parent.kind !== 273 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -43006,9 +43396,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 === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { + if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* 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)) { @@ -43031,27 +43421,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. @@ -43061,10 +43448,8 @@ var ts; return getTypeAtPosition(contextualSignature, indexOfParameter); } // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -43095,7 +43480,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182 /* BindingElement */) { + if (parentDeclaration.kind !== 184 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -43177,7 +43562,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189 /* TaggedTemplateExpression */) { + if (template.parent.kind === 191 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -43225,8 +43610,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504 /* StructuredType */) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, /*noReductions*/ true); } function getIndexTypeOfContextualType(type, kind) { @@ -43255,8 +43651,8 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -43322,8 +43718,8 @@ var ts; case 95 /* NullKeyword */: case 71 /* Identifier */: return true; - case 185 /* PropertyAccessExpression */: - case 191 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 193 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -43342,14 +43738,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270 /* PropertyAssignment */) + if (prop.kind !== 273 /* PropertyAssignment */) continue; 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); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine @@ -43390,52 +43786,52 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 193 /* ArrowFunction */: - case 225 /* ReturnStatement */: + case 195 /* ArrowFunction */: + case 228 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 183 /* ArrayLiteralExpression */: { + case 185 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 211 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); + case 214 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191 /* ParenthesizedExpression */: { + case 193 /* 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 265 /* JsxExpression */: + case 268 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -43509,6 +43905,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -43519,8 +43916,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) @@ -43536,7 +43949,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -43581,11 +43995,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; + return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -43657,18 +44070,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 182 /* BindingElement */ && !!node.initializer) || - (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 184 /* BindingElement */ && !!node.initializer) || + (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -43693,13 +44107,17 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; + if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } @@ -43707,28 +44125,30 @@ 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 === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - 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); + else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { + if (e.kind !== 208 /* OmittedExpression */) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2 /* Subtype */); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2 /* Subtype */) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -43813,7 +44233,7 @@ var ts; var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -43827,11 +44247,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 /* PropertyAssignment */ || - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 273 /* PropertyAssignment */ || + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -43852,8 +44272,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 === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -43878,7 +44298,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272 /* SpreadAssignment */) { + else if (memberDecl.kind === 275 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -43972,13 +44392,16 @@ var ts; type.flags & 131072 /* Object */ && !isGenericMappedType(type) || type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { + function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -43986,6 +44409,9 @@ var ts; else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -44008,16 +44434,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - // TODO (yuisu): comment - switch (tagName.kind) { - case 185 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: - return false; - case 71 /* Identifier */: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -44060,7 +44477,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -44083,7 +44500,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 255 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 /* 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); @@ -44244,12 +44661,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -44286,6 +44715,10 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928 /* Type */); + } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -44692,7 +45125,7 @@ var ts; // sourceAttributesType is a type of an attributes properties. // i.e
// attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. @@ -44713,31 +45146,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -44784,9 +45193,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? + var errorNode = node.kind === 187 /* PropertyAccessExpression */ || node.kind === 235 /* VariableDeclaration */ ? node.name : - node.kind === 179 /* ImportType */ ? + node.kind === 181 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -44956,7 +45365,7 @@ 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 !== 185 /* PropertyAccessExpression */ || + if (node.kind !== 187 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; @@ -44988,16 +45397,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + else if (valueDeclaration.kind === 238 /* 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)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -45005,7 +45419,7 @@ var ts; switch (node.kind) { case 152 /* PropertyDeclaration */: return true; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -45061,13 +45475,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319 /* Value */); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319 /* Value */); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -45126,16 +45546,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179 /* ImportType */: + case 181 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -45169,7 +45589,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer.kind === 236 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -45198,7 +45618,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 /* ForInStatement */ && + if (node.kind === 224 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -45216,7 +45636,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 190 /* 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); @@ -45283,7 +45703,7 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (node.kind !== 150 /* Decorator */) { @@ -45349,14 +45769,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204 /* SpreadElement */) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -45368,12 +45785,12 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* 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 = node.typeArguments; - if (node.template.kind === 202 /* TemplateExpression */) { + if (node.template.kind === 204 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -45395,8 +45812,8 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 188 /* NewExpression */); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190 /* NewExpression */); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. @@ -45409,15 +45826,14 @@ var ts; } // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -45442,9 +45858,10 @@ var ts; // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1 /* InferUnionTypes */, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8 /* ReturnType */); @@ -45494,7 +45911,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -45509,11 +45926,13 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; 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 !== 206 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -45527,6 +45946,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) @@ -45544,6 +45967,35 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + // We are inferring from a spread expression in the last argument position, i.e. both the parameter + // and the argument are ...x forms. + return arg.kind === 213 /* SyntheticExpression */ ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -45603,7 +46055,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 190 /* 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. @@ -45617,24 +46069,32 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; 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 !== 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. - // In that case, we should check the argument. - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { + if (i === restIndex && (restType.flags & 65536 /* TypeParameter */ || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, /*context*/ undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + // 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. + // In that case, we should check the argument. + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } @@ -45644,9 +46104,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { + if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { return callee.expression; } } @@ -45661,10 +46121,10 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [undefined]; // TODO: GH#18217 - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -45681,7 +46141,28 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + // We have a spread argument in the last position and no other spread arguments. If the type + // of the argument is a tuple type, spread the tuple elements into the argument list. We can + // call checkExpressionCached because spread expressions never have a contextual type. + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213 /* SyntheticExpression */, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } /** @@ -45700,8 +46181,8 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; case 152 /* PropertyDeclaration */: @@ -45746,7 +46227,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* 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); @@ -45791,7 +46272,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -45846,7 +46327,7 @@ 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 === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -45895,7 +46376,7 @@ var ts; if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -45908,7 +46389,7 @@ 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 === 150 /* Decorator */ || - (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { + (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -45921,7 +46402,7 @@ var ts; // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -45941,7 +46422,7 @@ 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 === 189 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -46016,7 +46497,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 === 187 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 /* 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 @@ -46063,10 +46544,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -46181,11 +46662,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -46201,7 +46683,7 @@ var ts; 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)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -46380,8 +46862,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -46407,8 +46888,8 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -46484,16 +46965,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -46569,7 +47050,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -46583,7 +47065,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185 /* PropertyAccessExpression */) { + while (parent && parent.kind === 187 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -46615,7 +47097,7 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 188 /* NewExpression */) { + if (node.kind === 190 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 /* Constructor */ && @@ -46689,7 +47171,7 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -46746,9 +47228,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 234 /* FunctionDeclaration */ + ? 237 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 232 /* VariableDeclaration */ + ? 235 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -46826,10 +47308,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1 /* Number */) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536 /* TypeParameter */) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -46868,11 +47447,11 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -46937,7 +47516,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213 /* Block */) { + if (func.body.kind !== 216 /* 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 @@ -47026,7 +47605,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -47051,7 +47630,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -47094,11 +47673,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; case 154 /* MethodDeclaration */: - return func.parent.kind === 184 /* ObjectLiteralExpression */; + return func.parent.kind === 186 /* ObjectLiteralExpression */; default: return false; } @@ -47122,7 +47701,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -47162,7 +47741,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -47223,7 +47802,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213 /* Block */) { + if (node.body.kind === 216 /* Block */) { checkSourceElement(node.body); } else { @@ -47236,10 +47815,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -47269,7 +47848,7 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && + (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* 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); @@ -47286,13 +47865,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* 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 === 246 /* NamespaceImport */; + return !!declaration && declaration.kind === 249 /* NamespaceImport */; } } } @@ -47301,7 +47880,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 !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -47310,7 +47889,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { + if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -47487,7 +48066,7 @@ 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 === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { var name = property.name; if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); @@ -47502,7 +48081,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 274 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -47514,7 +48093,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 === 272 /* SpreadAssignment */) { + else if (property.kind === 275 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -47549,27 +48128,23 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206 /* OmittedExpression */) { - if (element.kind !== 204 /* SpreadElement */) { + if (element.kind !== 208 /* OmittedExpression */) { + if (element.kind !== 206 /* SpreadElement */) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - // We still need to check element expression here because we may need to set appropriate flag on the expression - // such as NodeCheckFlags.LexicalThis on "this"expression. - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -47578,12 +48153,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -47592,7 +48170,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -47608,25 +48186,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184 /* ObjectLiteralExpression */) { + if (target.kind === 186 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183 /* ArrayLiteralExpression */) { + if (target.kind === 185 /* 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 === 272 /* SpreadAssignment */ ? + var error = target.parent.kind === 275 /* 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)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -47644,35 +48222,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 189 /* TaggedTemplateExpression */: - case 202 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - 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 */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 197 /* TypeOfExpression */: + case 211 /* NonNullExpression */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: return true; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -47684,9 +48262,9 @@ var ts; } return false; // Some forms listed here for clarity - 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 + case 198 /* VoidExpression */: // Explicit opt-out + case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -47702,7 +48280,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -47901,7 +48479,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -47922,7 +48500,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34 /* EqualsEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -47979,7 +48573,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' return anyType; @@ -48004,7 +48598,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263 /* JsxAttributes */) { + if (node.kind === 266 /* 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; @@ -48040,7 +48634,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; + return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -48142,7 +48736,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 === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 /* 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) { @@ -48192,8 +48786,8 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 188 /* 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) { @@ -48229,74 +48823,76 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checkCallExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return checkClassExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return checkAssertion(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return checkNonNullAssertion(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return checkMetaProperty(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkDeleteExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return checkVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return checkAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return undefinedWideningType; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return checkYieldExpression(node); - case 265 /* JsxExpression */: + case 213 /* SyntheticExpression */: + return node.type; + case 268 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return checkJsxElement(node, checkMode); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -48325,6 +48921,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 /* Instantiable */ && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -48351,7 +48950,7 @@ var ts; } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -48412,10 +49011,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 158 /* CallSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 163 /* FunctionType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -48436,7 +49035,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 === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { + else if (name.kind === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -48449,7 +49048,7 @@ var ts; checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + else if (node.kind === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -48514,7 +49113,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -48643,7 +49242,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* 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 @@ -48731,7 +49330,7 @@ var ts; // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -48753,7 +49352,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 === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -48904,11 +49503,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170 /* RestType */) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169 /* OptionalType */) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -48922,7 +49538,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 186 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 /* 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)); } @@ -48959,7 +49575,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* 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); @@ -48975,9 +49591,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 !== 236 /* InterfaceDeclaration */ && - n.parent.kind !== 235 /* ClassDeclaration */ && - n.parent.kind !== 205 /* ClassExpression */ && + if (n.parent.kind !== 239 /* InterfaceDeclaration */ && + n.parent.kind !== 238 /* ClassDeclaration */ && + n.parent.kind !== 207 /* 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 @@ -49107,7 +49723,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 /* 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 @@ -49118,7 +49734,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 === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -49247,22 +49863,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 249 /* ExportAssignment */: + case 252 /* 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 */; @@ -49270,17 +49886,17 @@ 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 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 248 /* 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 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 234 /* FunctionDeclaration */: - case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 237 /* FunctionDeclaration */: + case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -49551,7 +50167,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -49614,12 +50230,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -49651,7 +50267,7 @@ var ts; } } return commonEntityName; - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); case 162 /* TypeReference */: return node.typeName; @@ -49684,7 +50300,7 @@ var ts; 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -49773,7 +50389,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -49785,7 +50401,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -49868,27 +50484,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274 /* SourceFile */: - case 239 /* ModuleDeclaration */: - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 242 /* ModuleDeclaration */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -49902,7 +50518,7 @@ var ts; case 159 /* ConstructSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -49915,10 +50531,7 @@ var ts; 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.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -49948,7 +50561,7 @@ var ts; } break; case 160 /* IndexSignature */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: // Can't be private break; default: @@ -49964,7 +50577,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -49999,7 +50612,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -50017,9 +50630,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -50034,7 +50647,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0 /* Local */, unuseds.length === 1 @@ -50052,7 +50665,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -50073,7 +50686,7 @@ var ts; 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)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -50087,22 +50700,22 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; + return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 213 /* Block */) { + if (node.kind === 216 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -50197,7 +50810,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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 /* 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)); } @@ -50212,7 +50825,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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 277 /* 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)); } @@ -50247,7 +50860,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 === 232 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -50259,17 +50872,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 214 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 217 /* 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 === 213 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 240 /* ModuleBlock */ || - container.kind === 239 /* ModuleDeclaration */ || - container.kind === 274 /* SourceFile */); + (container.kind === 216 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 243 /* ModuleBlock */ || + container.kind === 242 /* ModuleDeclaration */ || + container.kind === 277 /* 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 @@ -50295,7 +50908,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 185 /* PropertyAccessExpression */) { + if (n.kind === 187 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -50315,7 +50928,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 182 /* BindingElement */) { + symbol.valueDeclaration.kind === 184 /* 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) { @@ -50368,8 +50981,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182 /* BindingElement */) { - if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 184 /* BindingElement */) { + if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -50390,7 +51003,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -50403,13 +51016,13 @@ var ts; // 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 !== 221 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -50426,8 +51039,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221 /* ForInStatement */) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -50442,7 +51055,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -50452,7 +51065,7 @@ var ts; 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 === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -50467,8 +51080,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || - (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || + (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -50507,7 +51120,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215 /* EmptyStatement */) { + if (node.thenStatement.kind === 218 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -50527,12 +51140,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -50566,14 +51179,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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. @@ -50587,7 +51200,7 @@ var ts; // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -50605,7 +51218,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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); @@ -50619,7 +51232,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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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)) { @@ -50983,7 +51596,7 @@ var ts; } } else if (func.kind === 155 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -50999,7 +51612,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -51032,7 +51645,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 === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -51044,7 +51657,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 269 /* 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. @@ -51073,7 +51686,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -51171,16 +51784,17 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } // perform property check if property or indexer is declared in 'type' // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || + if (propDeclaration && name && + (propDeclaration.kind === 202 /* BinaryExpression */ || + name.kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -51354,7 +51968,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); @@ -51366,6 +51980,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -51432,7 +52050,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -51451,7 +52069,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -51477,7 +52095,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; + return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -51516,7 +52134,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 === 205 /* ClassExpression */) { + if (derivedClassDecl.kind === 207 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -51630,7 +52248,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -51693,7 +52311,7 @@ var ts; } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -51708,7 +52326,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -51735,7 +52353,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -51745,7 +52363,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -51773,7 +52391,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: var identifier = expr; @@ -51781,14 +52399,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* 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 === 185 /* PropertyAccessExpression */) { + if (ex.kind === 187 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -51820,8 +52438,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -51835,7 +52453,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304 /* Ambient */) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -51851,7 +52469,7 @@ var ts; if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -51859,7 +52477,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 !== 238 /* EnumDeclaration */) { + if (declaration.kind !== 241 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -51882,8 +52500,8 @@ var ts; var declarations = symbol.declarations; 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))) && + if ((declaration.kind === 238 /* ClassDeclaration */ || + (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -51946,7 +52564,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, 235 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -51996,23 +52614,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* 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 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -52023,12 +52641,12 @@ var ts; break; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 234 /* FunctionDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -52056,7 +52674,7 @@ var ts; node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -52073,9 +52691,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - 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 */ ? + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -52108,14 +52726,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 === 252 /* ExportSpecifier */ ? + var message = node.kind === 255 /* 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 === 252 /* ExportSpecifier */ + && node.kind === 255 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -52142,7 +52760,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -52166,7 +52784,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -52202,10 +52820,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -52222,7 +52840,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -52251,8 +52869,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 === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -52340,7 +52958,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -52358,10 +52976,10 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -52399,111 +53017,113 @@ var ts; return checkArrayType(node); case 168 /* TupleType */: return checkTupleType(node); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: + case 169 /* OptionalType */: + case 170 /* RestType */: return checkSourceElement(node.type); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return checkTypeOperator(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return checkConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return checkInferType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return checkImportType(node); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 282 /* JSDocNonNullableType */: - case 281 /* JSDocNullableType */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: - case 287 /* JSDocTypeLiteral */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: + case 290 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 278 /* JSDocTypeExpression */: + case 281 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return checkMappedType(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return checkBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return checkVariableStatement(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return checkExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return checkIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return checkDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return checkWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return checkForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return checkForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkForOfStatement(node); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return checkReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return checkSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return checkLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return checkThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return checkTryStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return checkBindingElement(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return checkClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return checkImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return checkExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return checkExportAssignment(node); - case 215 /* EmptyStatement */: - case 231 /* DebuggerStatement */: + case 218 /* EmptyStatement */: + case 234 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -52580,15 +53200,15 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -52597,11 +53217,17 @@ var ts; case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: checkClassExpressionDeferred(node); break; + case 259 /* JsxSelfClosingElement */: + checkJsxSelfClosingElementDeferred(node); + break; + case 258 /* JsxElement */: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -52636,7 +53262,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -52730,13 +53356,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -52744,8 +53370,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* 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. @@ -52754,7 +53380,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -52803,10 +53429,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148 /* TypeParameter */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -52820,10 +53446,10 @@ var ts; return node.parent.kind === 162 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185 /* PropertyAccessExpression */) { + while (node.parent.kind === 187 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 207 /* ExpressionWithTypeArguments */; + return node.parent.kind === 209 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -52854,10 +53480,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -52883,7 +53509,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -52893,7 +53519,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 /* PropertyAccessExpression */ && + entityName.parent.kind === 187 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -52901,7 +53527,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 /* 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); @@ -52911,7 +53537,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, 243 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -52929,7 +53555,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 === 207 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -52945,10 +53571,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293 /* JSDocParameterTag */) { + if (entityName.parent.kind === 296 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 297 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 300 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -52965,12 +53591,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185 /* PropertyAccessExpression */) { + if (entityName.kind === 187 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -52983,7 +53609,7 @@ var ts; var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 262 /* JsxAttribute */) { + else if (entityName.parent.kind === 265 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161 /* TypePredicate */) { @@ -52993,7 +53619,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -53013,8 +53639,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 /* BindingElement */ && - grandParent.kind === 180 /* ObjectBindingPattern */ && + else if (parent.kind === 184 /* BindingElement */ && + grandParent.kind === 182 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -53025,7 +53651,7 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: @@ -53040,7 +53666,7 @@ var ts; return checkExpression(node).symbol; } // falls through - case 174 /* ThisType */: + case 176 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; @@ -53058,7 +53684,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 === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* 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); @@ -53076,14 +53702,14 @@ var ts; case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -53156,28 +53782,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 222 /* ForOfStatement */) { + if (expr.parent.kind === 225 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 200 /* BinaryExpression */) { + if (expr.parent.kind === 202 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 270 /* PropertyAssignment */) { + if (expr.parent.kind === 273 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -53256,7 +53882,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -53312,7 +53938,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* 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. @@ -53367,7 +53993,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 === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -53408,16 +54034,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -53427,7 +54053,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -53508,22 +54134,23 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273 /* EnumMember */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 276 /* EnumMember */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273 /* EnumMember */) { + if (node.kind === 276 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8 /* EnumMember */)) { // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -53661,7 +54288,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } @@ -53758,7 +54385,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; + return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -53770,7 +54397,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 === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -53821,7 +54448,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -53836,12 +54463,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 /* 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, 274 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 277 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -53849,10 +54476,14 @@ var ts; var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); // Initialize global symbol table var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -53926,6 +54557,32 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -54019,7 +54676,7 @@ var ts; } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { + if (node.kind !== 241 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -54039,7 +54696,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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -54062,7 +54719,7 @@ 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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149 /* Parameter */) { @@ -54098,7 +54755,7 @@ 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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149 /* Parameter */) { @@ -54107,8 +54764,8 @@ var ts; flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -54120,13 +54777,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } 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 === 240 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -54136,14 +54793,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 238 /* 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 === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 238 /* 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 */) { @@ -54185,7 +54842,7 @@ var ts; } return false; } - else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -54220,29 +54877,29 @@ var ts; 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 242 /* ModuleDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 149 /* Parameter */: return false; default: - if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return false; } switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 236 /* InterfaceDeclaration */: - case 214 /* VariableStatement */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 217 /* VariableStatement */: + case 240 /* TypeAliasDeclaration */: return true; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -54256,9 +54913,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -54391,7 +55048,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206 /* OmittedExpression */) { + if (arg.kind === 208 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -54472,15 +55129,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 202 /* 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 === 234 /* FunctionDeclaration */ || - node.kind === 192 /* FunctionExpression */ || + ts.Debug.assert(node.kind === 237 /* FunctionDeclaration */ || + node.kind === 194 /* FunctionExpression */ || node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -54504,7 +55161,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 === 272 /* SpreadAssignment */) { + if (prop.kind === 275 /* SpreadAssignment */) { continue; } var name = prop.name; @@ -54512,7 +55169,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 /* 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); @@ -54536,8 +55193,8 @@ 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 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -54587,7 +55244,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 === 264 /* JsxSpreadAttribute */) { + if (attr.kind === 267 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -54597,7 +55254,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -54606,12 +55263,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -54626,20 +55283,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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); @@ -54708,7 +55365,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* 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); @@ -54746,7 +55403,7 @@ var ts; return true; } if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 184 /* ObjectLiteralExpression */) { + if (node.parent.kind === 186 /* 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); @@ -54775,7 +55432,7 @@ var ts; 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 === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* 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 === 166 /* TypeLiteral */) { @@ -54789,11 +55446,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228 /* LabeledStatement */: + case 231 /* 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 === 223 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 226 /* 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); @@ -54801,8 +55458,8 @@ var ts; return false; } break; - case 227 /* SwitchStatement */: - if (node.kind === 224 /* BreakStatement */ && !node.label) { + case 230 /* SwitchStatement */: + if (node.kind === 227 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -54817,13 +55474,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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 === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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); @@ -54836,7 +55493,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 === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { + if (node.name.kind === 183 /* ArrayBindingPattern */ || node.name.kind === 182 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -54850,14 +55507,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { + if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -54868,7 +55525,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -54878,19 +55535,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 /* 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 && !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -54945,15 +55602,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return false; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -54963,7 +55620,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -55030,7 +55687,7 @@ var ts; return true; } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* 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; } @@ -55067,13 +55724,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - 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 */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 240 /* TypeAliasDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 253 /* ExportDeclaration */ || + node.kind === 252 /* ExportAssignment */ || + node.kind === 245 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -55082,7 +55739,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 214 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 217 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -55109,7 +55766,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 === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -55131,10 +55788,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, 178 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -55189,8 +55846,8 @@ var ts; /** 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 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -55198,14 +55855,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245 /* ImportClause */: // For default import - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: // For rename import `x as y` + case 248 /* ImportClause */: // For default import + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* 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 === 248 /* ImportSpecifier */; + return decl.parent.kind === 251 /* ImportSpecifier */; default: return false; } @@ -55221,8 +55878,12 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448 /* Literal */); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -55388,7 +56049,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 /* Node */ | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -55481,10 +56142,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 303 /* CommaListExpression */ ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147 /* ComputedPropertyName */); @@ -55847,14 +56507,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169 /* OptionalType */); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170 /* RestType */); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -55862,7 +56546,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -55881,7 +56565,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171 /* ConditionalType */); + var node = createSynthesizedNode(173 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -55899,7 +56583,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172 /* InferType */); + var node = createSynthesizedNode(174 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -55911,7 +56595,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179 /* ImportType */); + var node = createSynthesizedNode(181 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -55929,7 +56613,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173 /* ParenthesizedType */); + var node = createSynthesizedNode(175 /* ParenthesizedType */); node.type = type; return node; } @@ -55941,11 +56625,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174 /* ThisType */); + return createSynthesizedNode(176 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175 /* TypeOperator */); + var node = createSynthesizedNode(177 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -55956,7 +56640,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176 /* IndexedAccessType */); + var node = createSynthesizedNode(178 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -55970,7 +56654,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177 /* MappedType */); + var node = createSynthesizedNode(179 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -55988,7 +56672,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178 /* LiteralType */); + var node = createSynthesizedNode(180 /* LiteralType */); node.literal = literal; return node; } @@ -56001,7 +56685,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ObjectBindingPattern */); + var node = createSynthesizedNode(182 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56013,7 +56697,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181 /* ArrayBindingPattern */); + var node = createSynthesizedNode(183 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56025,7 +56709,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182 /* BindingElement */); + var node = createSynthesizedNode(184 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -56044,7 +56728,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -56058,7 +56742,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -56072,7 +56756,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185 /* PropertyAccessExpression */); + var node = createSynthesizedNode(187 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -56089,7 +56773,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186 /* ElementAccessExpression */); + var node = createSynthesizedNode(188 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -56103,7 +56787,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* CallExpression */); + var node = createSynthesizedNode(189 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -56119,7 +56803,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188 /* NewExpression */); + var node = createSynthesizedNode(190 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -56135,7 +56819,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -56158,7 +56842,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190 /* TypeAssertionExpression */); + var node = createSynthesizedNode(192 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -56172,7 +56856,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191 /* ParenthesizedExpression */); + var node = createSynthesizedNode(193 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -56184,7 +56868,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192 /* FunctionExpression */); + var node = createSynthesizedNode(194 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -56208,7 +56892,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193 /* ArrowFunction */); + var node = createSynthesizedNode(195 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -56242,7 +56926,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194 /* DeleteExpression */); + var node = createSynthesizedNode(196 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56254,7 +56938,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195 /* TypeOfExpression */); + var node = createSynthesizedNode(197 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56266,7 +56950,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196 /* VoidExpression */); + var node = createSynthesizedNode(198 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56278,7 +56962,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197 /* AwaitExpression */); + var node = createSynthesizedNode(199 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56290,7 +56974,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -56303,7 +56987,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -56316,7 +57000,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200 /* BinaryExpression */); + var node = createSynthesizedNode(202 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -56333,7 +57017,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201 /* ConditionalExpression */); + var node = createSynthesizedNode(203 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -56363,7 +57047,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202 /* TemplateExpression */); + var node = createSynthesizedNode(204 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -56401,7 +57085,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203 /* YieldExpression */); + var node = createSynthesizedNode(205 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -56415,7 +57099,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204 /* SpreadElement */); + var node = createSynthesizedNode(206 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -56427,7 +57111,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205 /* ClassExpression */); + var node = createSynthesizedNode(207 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56448,11 +57132,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206 /* OmittedExpression */); + return createSynthesizedNode(208 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -56466,7 +57150,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208 /* AsExpression */); + var node = createSynthesizedNode(210 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -56480,7 +57164,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209 /* NonNullExpression */); + var node = createSynthesizedNode(211 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -56492,7 +57176,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210 /* MetaProperty */); + var node = createSynthesizedNode(212 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -56506,7 +57190,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211 /* TemplateSpan */); + var node = createSynthesizedNode(214 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -56520,25 +57204,18 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212 /* SemicolonClassElement */); + return createSynthesizedNode(215 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213 /* Block */); + var block = createSynthesizedNode(216 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - /* @internal */ - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216 /* ExpressionStatement */); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -56546,7 +57223,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214 /* VariableStatement */); + var node = createSynthesizedNode(217 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -56561,21 +57238,27 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215 /* EmptyStatement */); + return createSynthesizedNode(218 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + ts.createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217 /* IfStatement */); + var node = createSynthesizedNode(220 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -56591,7 +57274,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218 /* DoStatement */); + var node = createSynthesizedNode(221 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -56605,7 +57288,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219 /* WhileStatement */); + var node = createSynthesizedNode(222 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -56619,7 +57302,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220 /* ForStatement */); + var node = createSynthesizedNode(223 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -56637,7 +57320,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForInStatement */); + var node = createSynthesizedNode(224 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -56653,7 +57336,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222 /* ForOfStatement */); + var node = createSynthesizedNode(225 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -56671,7 +57354,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223 /* ContinueStatement */); + var node = createSynthesizedNode(226 /* ContinueStatement */); node.label = asName(label); return node; } @@ -56683,7 +57366,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224 /* BreakStatement */); + var node = createSynthesizedNode(227 /* BreakStatement */); node.label = asName(label); return node; } @@ -56695,7 +57378,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225 /* ReturnStatement */); + var node = createSynthesizedNode(228 /* ReturnStatement */); node.expression = expression; return node; } @@ -56707,7 +57390,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226 /* WithStatement */); + var node = createSynthesizedNode(229 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -56721,7 +57404,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227 /* SwitchStatement */); + var node = createSynthesizedNode(230 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -56735,7 +57418,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228 /* LabeledStatement */); + var node = createSynthesizedNode(231 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -56749,7 +57432,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229 /* ThrowStatement */); + var node = createSynthesizedNode(232 /* ThrowStatement */); node.expression = expression; return node; } @@ -56761,7 +57444,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230 /* TryStatement */); + var node = createSynthesizedNode(233 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -56777,11 +57460,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231 /* DebuggerStatement */); + return createSynthesizedNode(234 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232 /* VariableDeclaration */); + var node = createSynthesizedNode(235 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -56798,7 +57481,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(233 /* VariableDeclarationList */); + var node = createSynthesizedNode(236 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -56811,7 +57494,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234 /* FunctionDeclaration */); + var node = createSynthesizedNode(237 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -56837,7 +57520,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* ClassDeclaration */); + var node = createSynthesizedNode(238 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56859,7 +57542,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236 /* InterfaceDeclaration */); + var node = createSynthesizedNode(239 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56881,7 +57564,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56901,7 +57584,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238 /* EnumDeclaration */); + var node = createSynthesizedNode(241 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56920,7 +57603,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* ModuleDeclaration */); + var node = createSynthesizedNode(242 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -56939,7 +57622,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240 /* ModuleBlock */); + var node = createSynthesizedNode(243 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -56951,7 +57634,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241 /* CaseBlock */); + var node = createSynthesizedNode(244 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -56963,7 +57646,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -56975,7 +57658,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56993,7 +57676,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244 /* ImportDeclaration */); + var node = createSynthesizedNode(247 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -57011,7 +57694,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245 /* ImportClause */); + var node = createSynthesizedNode(248 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -57025,7 +57708,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246 /* NamespaceImport */); + var node = createSynthesizedNode(249 /* NamespaceImport */); node.name = name; return node; } @@ -57037,7 +57720,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247 /* NamedImports */); + var node = createSynthesizedNode(250 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -57049,7 +57732,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248 /* ImportSpecifier */); + var node = createSynthesizedNode(251 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -57063,7 +57746,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249 /* ExportAssignment */); + var node = createSynthesizedNode(252 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -57080,7 +57763,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ExportDeclaration */); + var node = createSynthesizedNode(253 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -57098,7 +57781,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251 /* NamedExports */); + var node = createSynthesizedNode(254 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -57110,7 +57793,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252 /* ExportSpecifier */); + var node = createSynthesizedNode(255 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -57125,7 +57808,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254 /* ExternalModuleReference */); + var node = createSynthesizedNode(257 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -57138,7 +57821,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255 /* JsxElement */); + var node = createSynthesizedNode(258 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -57154,7 +57837,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57170,7 +57853,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257 /* JsxOpeningElement */); + var node = createSynthesizedNode(260 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57186,7 +57869,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258 /* JsxClosingElement */); + var node = createSynthesizedNode(261 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -57198,7 +57881,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259 /* JsxFragment */); + var node = createSynthesizedNode(262 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -57214,7 +57897,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262 /* JsxAttribute */); + var node = createSynthesizedNode(265 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -57228,7 +57911,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263 /* JsxAttributes */); + var node = createSynthesizedNode(266 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -57240,7 +57923,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -57252,7 +57935,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265 /* JsxExpression */); + var node = createSynthesizedNode(268 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -57266,7 +57949,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266 /* CaseClause */); + var node = createSynthesizedNode(269 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -57280,7 +57963,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267 /* DefaultClause */); + var node = createSynthesizedNode(270 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -57292,7 +57975,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268 /* HeritageClause */); + var node = createSynthesizedNode(271 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -57305,7 +57988,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269 /* CatchClause */); + var node = createSynthesizedNode(272 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -57320,7 +58003,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270 /* PropertyAssignment */); + var node = createSynthesizedNode(273 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -57335,7 +58018,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -57349,7 +58032,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272 /* SpreadAssignment */); + var node = createSynthesizedNode(275 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -57362,7 +58045,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273 /* EnumMember */); + var node = createSynthesizedNode(276 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -57383,7 +58066,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274 /* SourceFile */); + var updated = createSynthesizedNode(277 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -57467,7 +58150,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301 /* NotEmittedStatement */); + var node = createSynthesizedNode(304 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -57479,7 +58162,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(308 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57491,7 +58174,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(307 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57506,7 +58189,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(302 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(305 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -57522,7 +58205,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 === 303 /* CommaListExpression */) { + if (node.kind === 306 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -57532,7 +58215,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303 /* CommaListExpression */); + var node = createSynthesizedNode(306 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -57545,14 +58228,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275 /* Bundle */); + var node = ts.createNode(278 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276 /* UnparsedSource */); + var node = ts.createNode(279 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -57560,7 +58243,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277 /* InputFiles */); + var node = ts.createNode(280 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -57703,7 +58386,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 === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -58214,7 +58897,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -58232,13 +58915,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -58265,7 +58948,7 @@ var ts; } else { switch (callee.kind) { - case 185 /* PropertyAccessExpression */: { + case 187 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58278,7 +58961,7 @@ var ts; } break; } - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58338,9 +59021,9 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -58665,7 +59348,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 === 191 /* ParenthesizedExpression */) { + if (skipped.kind === 193 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -58699,8 +59382,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(200 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -58709,7 +59392,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 203 /* YieldExpression */) { + && operand.kind === 205 /* YieldExpression */) { return false; } return true; @@ -58797,7 +59480,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -58812,7 +59495,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -58826,8 +59509,7 @@ 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 === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 303 /* CommaListExpression */ + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } @@ -58845,10 +59527,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 /* ClassExpression */ || - check.kind === 192 /* FunctionExpression */ || - check.kind === 303 /* CommaListExpression */ || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) + return check.kind === 207 /* ClassExpression */ || + check.kind === 194 /* FunctionExpression */ || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -58862,9 +59543,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.createParen(expression); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -58887,7 +59568,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -58925,7 +59606,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -58936,27 +59617,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { + if (kind === 194 /* FunctionExpression */ || kind === 195 /* 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 === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { + if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: return ts.createParenthesizedType(member); @@ -58967,8 +59648,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 172 /* InferType */: + case 177 /* TypeOperator */: + case 174 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -58994,25 +59675,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: node = node.operand; continue; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: node = node.left; continue; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: node = node.condition; continue; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: - node = node.expression; - continue; - case 302 /* PartiallyEmittedExpression */: + case 210 /* AsExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 211 /* NonNullExpression */: + case 305 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -59020,12 +59701,17 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || + node.kind === 306 /* CommaListExpression */; + } + ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; @@ -59036,13 +59722,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 209 /* NonNullExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 211 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -59067,7 +59753,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { node = node.expression; } return node; @@ -59075,11 +59761,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - 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 302 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -59097,7 +59783,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 191 /* ParenthesizedExpression */ + return node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -59162,10 +59848,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -59284,7 +59970,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -59296,11 +59982,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -59333,11 +60019,11 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 204 /* SpreadElement */: - case 272 /* SpreadAssignment */: + case 206 /* SpreadElement */: + case 275 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -59349,7 +60035,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -59361,7 +60047,7 @@ var ts; : propertyName; } break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -59373,7 +60059,7 @@ var ts; : propertyName; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -59391,13 +60077,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -59437,11 +60123,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -59565,7 +60251,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -59602,7 +60288,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { return node; } switch (kind) { @@ -59657,217 +60343,221 @@ var ts; case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168 /* TupleType */: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* UnionType */: + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 169 /* OptionalType */: + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* RestType */: + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 171 /* ConditionalType */: + case 173 /* 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 172 /* InferType */: + case 174 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179 /* ImportType */: + case 181 /* 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 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177 /* MappedType */: + case 179 /* 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 178 /* LiteralType */: + case 180 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182 /* BindingElement */: + case 184 /* 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 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* FunctionExpression */: + case 194 /* 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 193 /* ArrowFunction */: + case 195 /* 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 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201 /* ConditionalExpression */: + case 203 /* 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 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 213 /* Block */: + case 216 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 216 /* ExpressionStatement */: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* IfStatement */: + case 219 /* ExpressionStatement */: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* 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 218 /* DoStatement */: + case 221 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: + case 224 /* 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 222 /* ForOfStatement */: + case 225 /* 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 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234 /* FunctionDeclaration */: + case 237 /* 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 235 /* ClassDeclaration */: + case 238 /* 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 236 /* InterfaceDeclaration */: + case 239 /* 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 237 /* TypeAliasDeclaration */: + case 240 /* 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 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250 /* ExportDeclaration */: + case 253 /* 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 251 /* NamedExports */: + case 254 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -59913,17 +60603,17 @@ var ts; return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 212 /* SemicolonClassElement */: - case 215 /* EmptyStatement */: - case 206 /* OmittedExpression */: - case 231 /* DebuggerStatement */: - case 301 /* NotEmittedStatement */: + case 215 /* SemicolonClassElement */: + case 218 /* EmptyStatement */: + case 208 /* OmittedExpression */: + case 234 /* DebuggerStatement */: + case 304 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -59990,49 +60680,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* NewExpression */: + case 190 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -60040,123 +60730,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ArrowFunction */: + case 195 /* 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 191 /* ParenthesizedExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208 /* AsExpression */: + case 210 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 213 /* Block */: + case 216 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219 /* WhileStatement */: - case 226 /* WithStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60165,7 +60855,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60173,139 +60863,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -60378,7 +61068,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 !== 207 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -60622,7 +61312,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -60769,7 +61458,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -60815,7 +61504,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -60823,13 +61512,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + case 246 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -60859,13 +61548,13 @@ var ts; } } break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -60873,7 +61562,7 @@ var ts; } } break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -60893,7 +61582,7 @@ var ts; } } break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -61509,13 +62198,14 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -61539,14 +62229,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* 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 === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -61574,16 +62264,18 @@ var ts; */ function saveStateAndInvoke(node, f) { // Save state - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } /** @@ -61593,15 +62285,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 240 /* ModuleBlock */: - case 213 /* Block */: - currentScope = node; + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 243 /* ModuleBlock */: + case 216 /* Block */: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -61613,7 +62306,11 @@ 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 === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } + if (ts.isClassDeclaration(node)) { + // XXX: should probably also cover interfaces and type aliases that can have type variables? + currentNameScope = node; } break; } @@ -61657,10 +62354,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -61681,13 +62378,13 @@ var ts; return node; } switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -61707,11 +62404,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 250 /* ExportDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 245 /* ImportClause */ || - (node.kind === 243 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 254 /* ExternalModuleReference */)) { + if (node.kind === 253 /* ExportDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 248 /* ImportClause */ || + (node.kind === 246 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 257 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -61753,7 +62450,7 @@ var ts; case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -61794,6 +62491,8 @@ var ts; // TypeScript accessibility and readonly modifiers are elided. case 167 /* ArrayType */: case 168 /* TupleType */: + case 169 /* OptionalType */: + case 170 /* RestType */: case 166 /* TypeLiteral */: case 161 /* TypePredicate */: case 148 /* TypeParameter */: @@ -61809,36 +62508,36 @@ var ts; 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 */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 175 /* ParenthesizedType */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: // TypeScript type nodes are elided. case 160 /* IndexSignature */: // TypeScript index signatures are elided. case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; 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 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; case 155 /* Constructor */: return visitConstructor(node); - case 236 /* InterfaceDeclaration */: + case 239 /* 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61849,7 +62548,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61860,13 +62559,13 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); case 154 /* MethodDeclaration */: @@ -61879,13 +62578,13 @@ var ts; case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case 149 /* Parameter */: @@ -61898,35 +62597,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -61962,7 +62661,7 @@ var ts; var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) @@ -62005,7 +62704,7 @@ var ts; var statements = [classStatement]; // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -62366,7 +63065,7 @@ var ts; // // super(...arguments); // - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } // Add the property initializers. Transforms this: @@ -62408,7 +63107,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -62445,7 +63144,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -62492,7 +63191,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -62795,7 +63494,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } /** @@ -62922,8 +63621,8 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -62945,8 +63644,8 @@ var ts; return serializeTypeNode(node.type); case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: @@ -63034,7 +63733,7 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return serializeTypeNode(node.type); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -63049,7 +63748,7 @@ var ts; return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -63069,18 +63768,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: return serializeUnionOrIntersectionType(node); case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: case 142 /* UnknownKeyword */: - case 174 /* ThisType */: - case 179 /* ImportType */: + case 176 /* ThisType */: + case 181 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63093,7 +63792,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -63132,7 +63831,7 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); @@ -63179,7 +63878,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. + name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -63513,7 +64212,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -63594,7 +64293,7 @@ var ts; * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -63618,7 +64317,7 @@ var ts; // enum body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63643,7 +64342,7 @@ var ts; // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63691,7 +64390,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } /** * Transforms the value of an enum member. @@ -63769,12 +64468,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 === 274 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 277 /* 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 === 238 /* EnumDeclaration */) { + if (node.kind === 241 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -63836,7 +64535,7 @@ var ts; // module body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63860,7 +64559,7 @@ var ts; // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63893,7 +64592,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240 /* ModuleBlock */) { + if (body.kind === 243 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -63939,13 +64638,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 !== 240 /* ModuleBlock */) { + if (body.kind !== 243 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -63986,7 +64685,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 246 /* NamespaceImport */) { + if (node.kind === 249 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -64141,17 +64840,17 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -64218,16 +64917,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(271 /* ShorthandPropertyAssignment */); + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(239 /* ModuleDeclaration */); + context.enableEmitNotification(242 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; } /** * Hook for node emit. @@ -64288,9 +64987,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -64328,9 +65027,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 !== 274 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); + if (container && container.kind !== 277 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -64465,15 +65164,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -64482,27 +65181,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - 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 */: + case 216 /* Block */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 229 /* WithStatement */: + case 231 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -64537,7 +65236,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -64703,7 +65402,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 === 193 /* ArrowFunction */; + var isArrowFunction = node.kind === 195 /* 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 @@ -64776,11 +65475,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -64824,11 +65523,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -64860,7 +65559,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -64959,25 +65658,25 @@ var ts; return node; } switch (node.kind) { - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitVoidExpression(node); case 155 /* Constructor */: return visitConstructorDeclaration(node); @@ -64987,19 +65686,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); case 149 /* Parameter */: return visitParameter(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -65033,7 +65732,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -65045,7 +65744,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 === 272 /* SpreadAssignment */) { + if (e.kind === 275 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -65054,7 +65753,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -65072,7 +65771,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 !== 184 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -65211,13 +65910,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -65385,11 +66084,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -65433,11 +66132,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -65469,7 +66168,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -65582,13 +66281,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -65598,13 +66297,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -65679,7 +66378,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265 /* JsxExpression */) { + else if (node.kind === 268 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -65773,7 +66472,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255 /* JsxElement */) { + if (node.kind === 258 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -66079,7 +66778,7 @@ var ts; return node; } switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66312,13 +67011,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 225 /* ReturnStatement */ + && node.kind === 228 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -66346,63 +67045,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return visitClassExpression(node); case 149 /* Parameter */: return visitParameter(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -66413,28 +67112,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitMetaProperty(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -66521,14 +67220,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 === 224 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -66539,7 +67238,7 @@ var ts; } } else { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -66656,7 +67355,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -66720,7 +67419,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), /*location*/ extendsClauseElement)); } } @@ -66839,11 +67538,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 225 /* ReturnStatement */) { + if (statement.kind === 228 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 217 /* IfStatement */) { + else if (statement.kind === 220 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -66851,7 +67550,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 213 /* Block */) { + else if (statement.kind === 216 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -66909,7 +67608,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -66919,8 +67618,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 /* BinaryExpression */ - || superCallExpression.left.kind !== 187 /* CallExpression */) { + if (superCallExpression.kind !== 202 /* BinaryExpression */ + || superCallExpression.left.kind !== 189 /* 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. @@ -67035,7 +67734,7 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -67049,7 +67748,7 @@ var ts; function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -67101,7 +67800,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ - ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) @@ -67117,7 +67816,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -67137,7 +67836,7 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return statements; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -67151,8 +67850,8 @@ var ts; // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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()); @@ -67183,7 +67882,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: @@ -67227,7 +67926,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -67245,7 +67944,7 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); + var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. @@ -67388,7 +68087,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 === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -67433,7 +68132,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193 /* ArrowFunction */); + ts.Debug.assert(node.kind === 195 /* 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 @@ -67501,10 +68200,10 @@ 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 191 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + case 193 /* ParenthesizedExpression */: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 202 /* BinaryExpression */: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); } @@ -67522,9 +68221,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 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -67566,7 +68265,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -67725,14 +68424,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -67790,11 +68489,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -67883,13 +68582,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -67988,11 +68687,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -68156,7 +68855,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -68173,7 +68872,7 @@ var ts; ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { @@ -68282,10 +68981,10 @@ var ts; case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -68537,7 +69236,7 @@ var ts; statements.push(funcStatements[classBodyStart]); classBodyStart++; // Add the class alias following the declaration. - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } // Find the trailing 'return' statement (4) while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { @@ -68674,7 +69373,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -68941,9 +69640,9 @@ var ts; context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(193 /* ArrowFunction */); - context.enableEmitNotification(192 /* FunctionExpression */); - context.enableEmitNotification(234 /* FunctionDeclaration */); + context.enableEmitNotification(195 /* ArrowFunction */); + context.enableEmitNotification(194 /* FunctionExpression */); + context.enableEmitNotification(237 /* FunctionDeclaration */); } } /** @@ -68984,10 +69683,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 235 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -69069,11 +69768,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -69081,7 +69780,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -69134,15 +69833,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257 /* JsxOpeningElement */); - context.enableEmitNotification(258 /* JsxClosingElement */); - context.enableEmitNotification(256 /* JsxSelfClosingElement */); + context.enableEmitNotification(260 /* JsxOpeningElement */); + context.enableEmitNotification(261 /* JsxClosingElement */); + context.enableEmitNotification(259 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(270 /* PropertyAssignment */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(273 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -69161,9 +69860,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -69495,13 +70194,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -69514,24 +70213,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return visitBreakStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return visitContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -69552,21 +70251,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitConditionalExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69579,9 +70278,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -69757,7 +70456,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } /** @@ -69809,7 +70508,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -69821,7 +70520,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -69945,7 +70644,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* Statement */, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -70098,7 +70797,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -70197,35 +70896,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: return transformAndEmitBlock(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return transformAndEmitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return transformAndEmitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return transformAndEmitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return transformAndEmitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -70262,7 +70961,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -70413,7 +71112,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -70423,7 +71122,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -70484,7 +71183,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); @@ -70507,7 +71206,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -70655,7 +71354,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -70668,7 +71367,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -71531,7 +72230,7 @@ var ts; // indicate entry into a protected region by pushing the label numbers // for each block in the protected region. var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, [ ts.createArrayLiteral([ createLabel(startLabel), @@ -71545,7 +72244,7 @@ var ts; if (markLabelEnd) { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -71703,7 +72402,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -71897,11 +72596,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported 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.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(277 /* 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. @@ -71994,7 +72693,7 @@ var ts; // // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, + ts.createExpressionStatement(ts.createCall(define, /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ // Add the dependency array argument: // @@ -72045,9 +72744,9 @@ var ts; ts.createIdentifier("exports") ])) ]), - ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -72071,7 +72770,7 @@ var ts; // } // })(function ...) var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, + ts.createExpressionStatement(ts.createCall(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // @@ -72150,7 +72849,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. @@ -72205,7 +72904,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); @@ -72223,23 +72922,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -72266,17 +72965,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -72370,7 +73069,7 @@ var ts; ts.createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; @@ -72465,7 +73164,7 @@ var ts; if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -72533,7 +73232,7 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( @@ -72546,7 +73245,7 @@ var ts; } else { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -72585,13 +73284,13 @@ var ts; for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { // export * from "mod"; - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } /** @@ -72697,7 +73396,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -72758,7 +73457,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -72813,10 +73512,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -72946,10 +73645,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), @@ -72970,7 +73669,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, location, allowComments) { - var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -73015,7 +73714,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -73079,10 +73778,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -73103,7 +73802,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -73178,7 +73877,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -73254,11 +73953,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - 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. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(277 /* 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. @@ -73320,7 +74019,7 @@ var ts; var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) @@ -73479,7 +74178,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -73504,7 +74203,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250 /* ExportDeclaration */) { + if (externalImport.kind !== 253 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -73558,9 +74257,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) ])), - ts.createStatement(ts.createCall(exportFunction, + ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) ], /*multiline*/ true)); } @@ -73582,19 +74281,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -73610,7 +74309,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { @@ -73619,7 +74318,7 @@ var ts; // emit as: // // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, /*typeArguments*/ undefined, [parameterName]))); } break; @@ -73644,15 +74343,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -73753,7 +74452,7 @@ var ts; var name = ts.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -73790,7 +74489,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -73828,7 +74527,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 === 274 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 277 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -73892,7 +74591,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 === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -73954,10 +74653,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -74109,7 +74808,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -74137,43 +74836,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitDefaultClause(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitTryStatement(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -74356,7 +75055,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 200 /* BinaryExpression */) { + && node.kind === 202 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -74421,7 +75120,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274 /* SourceFile */; + return container !== undefined && container.kind === 277 /* SourceFile */; } else { return false; @@ -74454,7 +75153,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -74502,7 +75201,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -74538,10 +75237,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -74634,14 +75333,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* 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 === 199 /* PostfixUnaryExpression */) { + if (node.kind === 201 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -74663,7 +75362,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -74702,7 +75401,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274 /* SourceFile */); + context.enableEmitNotification(277 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -74731,10 +75430,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -74841,7 +75540,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74870,7 +75569,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74917,7 +75616,7 @@ var ts; 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 === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* 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 : @@ -74936,7 +75635,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 === 235 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 238 /* 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 : @@ -75027,7 +75726,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -75041,7 +75740,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234 /* FunctionDeclaration */: + case 237 /* 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 : @@ -75097,7 +75796,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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 : @@ -75110,7 +75809,7 @@ 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 163 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -75125,10 +75824,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159 /* ConstructSignature */: @@ -75142,17 +75841,17 @@ var ts; 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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -75167,7 +75866,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 235 /* ClassDeclaration */) { + if (node.parent.parent.kind === 238 /* 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 : @@ -75264,7 +75963,13 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + // If it is visible via `// `, then we should just use that + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -75319,10 +76024,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -75350,7 +76055,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -75448,7 +76153,7 @@ var ts; return name; } else { - if (name.kind === 181 /* ArrayBindingPattern */) { + if (name.kind === 183 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -75456,7 +76161,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206 /* OmittedExpression */) { + if (elem.kind === 208 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -75514,7 +76219,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 /* Parameter */ @@ -75536,20 +76241,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return false; } return false; @@ -75603,7 +76308,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -75615,7 +76320,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -75642,7 +76347,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 === 246 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 249 /* 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; @@ -75747,14 +76452,14 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* 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 207 /* ExpressionWithTypeArguments */: { + case 209 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -75808,7 +76513,7 @@ var ts; return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -75822,7 +76527,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171 /* ConditionalType */: { + case 173 /* 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); @@ -75840,7 +76545,7 @@ var ts; case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179 /* ImportType */: { + case 181 /* 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)); @@ -75879,7 +76584,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250 /* ExportDeclaration */: { + case 253 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -75888,7 +76593,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -75918,10 +76623,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -75942,24 +76647,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 240 /* 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 236 /* InterfaceDeclaration */: { + case 239 /* 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 234 /* FunctionDeclaration */: { + case 237 /* 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 239 /* ModuleDeclaration */: { + case 242 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240 /* ModuleBlock */) { + if (inner && inner.kind === 243 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -75980,7 +76685,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 235 /* ClassDeclaration */: { + case 238 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -76020,7 +76725,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(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"); // TODO: GH#18217 @@ -76050,10 +76755,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238 /* EnumDeclaration */: { + case 241 /* 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; @@ -76072,7 +76777,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239 /* ModuleDeclaration */) { + if (input.kind === 242 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -76093,7 +76798,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206 /* OmittedExpression */) { + if (e.kind === 208 /* OmittedExpression */) { return; } if (e.name) { @@ -76147,7 +76852,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 === 274 /* SourceFile */; + var parentIsFile = node.parent.kind === 277 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -76168,7 +76873,7 @@ var ts; var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3 /* MultiLineCommentTrivia */) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -76182,7 +76887,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -76195,7 +76900,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* InterfaceDeclaration */) { return true; } return false; @@ -76224,7 +76929,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: @@ -76234,17 +76939,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - 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 */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 217 /* VariableStatement */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return true; } return false; @@ -76261,14 +76966,14 @@ var ts; case 153 /* MethodSignature */: case 158 /* CallSignature */: case 160 /* IndexSignature */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 148 /* TypeParameter */: - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: case 162 /* TypeReference */: - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 179 /* ImportType */: + case 181 /* ImportType */: return true; } return false; @@ -76344,7 +77049,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(306 /* Count */); + var enabledSyntaxKindFeatures = new Array(309 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -76679,7 +77384,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap @@ -76689,7 +77393,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 277 /* 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)); @@ -76780,7 +77484,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** * Emits a mapping. @@ -76840,6 +77543,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -76850,50 +77554,55 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { // empty } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); // First, decode the old component sourcemap - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -76910,7 +77619,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -76965,13 +77674,15 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - // 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 - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + // 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 + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -77087,7 +77798,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 304 /* 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 */; @@ -77108,7 +77819,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 === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -77450,7 +78161,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275 /* Bundle */) { + if (sourceFile.kind === 278 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; @@ -77585,6 +78296,11 @@ var ts; // Setup and perform the transformation to retrieve declarations from the input files var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + // Checker wont collect the linked aliases since thats only done when declaration is enabled. + // Do that here when emitting only dts files + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -77612,9 +78328,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71 /* Identifier */) { + resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -77714,9 +78443,9 @@ var ts; break; } switch (node.kind) { - case 274 /* SourceFile */: return printFile(node); - case 275 /* Bundle */: return printBundle(node); - case 276 /* UnparsedSource */: return printUnparsedSource(node); + case 277 /* SourceFile */: return printFile(node); + case 278 /* Bundle */: return printBundle(node); + case 279 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -77861,7 +78590,7 @@ var ts; } return pipelineEmitWithoutComments; case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { return pipelineEmitWithSourceMap; } // falls through @@ -77887,7 +78616,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); + ts.Debug.assert(hint !== 0 /* SourceFile */); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -77906,7 +78635,7 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 276 /* UnparsedSource */: + case 279 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: @@ -77951,7 +78680,7 @@ var ts; return emitTypeReference(node); case 163 /* FunctionType */: return emitFunctionType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 164 /* ConstructorType */: return emitConstructorType(node); @@ -77963,178 +78692,181 @@ var ts; return emitArrayType(node); case 168 /* TupleType */: return emitTupleType(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return emitOptionalType(node); + case 171 /* UnionType */: return emitUnionType(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return emitIntersectionType(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return emitConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return emitInferType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return emitParenthesizedType(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return emitThisType(); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return emitTypeOperator(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return emitMappedType(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return emitLiteralType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return emitImportTypeNode(node); - case 279 /* JSDocAllType */: + case 282 /* JSDocAllType */: write("*"); return; - case 280 /* JSDocUnknownType */: + case 283 /* JSDocUnknownType */: write("?"); return; - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 285 /* JSDocVariadicType */: - return emitJSDocVariadicType(node); + case 170 /* RestType */: + case 288 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return emitBindingElement(node); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return emitTemplateSpan(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 213 /* Block */: + case 216 /* Block */: return emitBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return emitVariableStatement(node); - case 215 /* EmptyStatement */: + case 218 /* EmptyStatement */: return emitEmptyStatement(); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return emitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return emitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return emitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return emitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return emitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return emitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return emitForOfStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return emitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return emitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return emitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return emitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return emitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return emitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return emitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return emitTryStatement(node); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return emitClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return emitModuleBlock(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return emitCaseBlock(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return emitImportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return emitImportClause(node); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return emitNamespaceImport(node); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return emitNamedImports(node); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return emitImportSpecifier(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return emitExportDeclaration(node); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return emitNamedExports(node); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return emitExportSpecifier(node); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return; // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 258 /* JsxClosingElement */: - case 261 /* JsxClosingFragment */: + case 261 /* JsxClosingElement */: + case 264 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return emitJsxAttribute(node); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return emitJsxAttributes(node); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return emitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return emitDefaultClause(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return emitHeritageClause(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -78169,71 +78901,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return emitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return emitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return emitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return emitArrowFunction(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return emitDeleteExpression(node); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return emitVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return emitAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return emitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return emitConditionalExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return emitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return emitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return emitSpreadExpression(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return emitClassExpression(node); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: return emitAsExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return emitNonNullExpression(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return emitJsxElement(node); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return emitCommaList(node); } } @@ -78250,7 +78982,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 /* Bundle */ ? node : undefined; + var bundle = node.kind === 278 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -78376,7 +79108,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -78545,7 +79277,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -78554,6 +79286,10 @@ var ts; emitList(node, node.elementTypes, 272 /* TupleTypeElements */); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260 /* UnionTypeConstituents */); } @@ -78835,7 +79571,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 === 198 /* PrefixUnaryExpression */ + return operand.kind === 200 /* 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 */))); } @@ -78955,7 +79691,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217 /* IfStatement */) { + if (node.elseStatement.kind === 220 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -79026,7 +79762,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { emit(node); } else { @@ -79128,7 +79864,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272 /* VariableDeclarationList */); } @@ -79321,7 +80057,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239 /* ModuleDeclaration */) { + while (body.kind === 242 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -80246,7 +80982,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -80311,81 +81047,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: ts.forEach(node.statements, generateNames); break; - case 228 /* LabeledStatement */: - case 226 /* WithStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 231 /* LabeledStatement */: + case 229 /* WithStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: generateNames(node.statement); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: generateNames(node.declarationList); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: generateNames(node.importClause); break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -80394,8 +81130,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 152 /* PropertyDeclaration */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -80581,17 +81317,17 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 252 /* ExportAssignment */: return generateNameForExportDefault(); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return generateNameForClassExpression(); case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -81252,17 +81988,20 @@ var ts; } return context; } - function formatLocation(file, start, host) { + /* @internal */ + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -81281,11 +82020,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -82012,7 +82751,16 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + // Use local caches + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + // Before falling back to the host + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -82272,10 +83020,10 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: - case 232 /* VariableDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: + case 235 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -82283,41 +83031,41 @@ var ts; } } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268 /* HeritageClause */: + case 271 /* 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 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -82330,25 +83078,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 235 /* ClassDeclaration */: + case 238 /* 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 */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* 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 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); } break; case 152 /* PropertyDeclaration */: @@ -82370,11 +83118,11 @@ var ts; return; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -83040,14 +83788,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -84701,11 +85449,12 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - // Note: fromSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + // Note: importingSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -84718,7 +85467,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); 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); @@ -84736,13 +85485,13 @@ var ts; 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); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } 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); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -84812,11 +85561,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0 /* EqualTo */) { resolvedParts.pop(); originalParts.pop(); } @@ -84850,17 +85600,16 @@ var ts; return [target]; } /** - * Looks for a existing imports that use symlinks to this module. + * Looks for existing imports that use symlinks to this module. * Only if no symlink is available, the real path will be used. */ - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -84936,7 +85685,7 @@ var ts; var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // 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))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); @@ -85344,7 +86093,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; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; 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); @@ -85876,16 +86625,20 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */) ? ".jsx" /* Jsx */ : ".js" /* Js */); + var newExtension = ts.fileExtensionIs(inputFileName, ".json" /* Json */) ? ".json" /* Json */ : + ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -86057,9 +86810,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -86109,7 +86859,7 @@ var ts; // Everything is broken - we don't even know what to watch. Give up. return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { // Watch this file @@ -86136,7 +86886,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -86341,14 +87091,18 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -86356,7 +87110,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -86652,12 +87410,12 @@ var ts; } // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -86726,7 +87484,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; @@ -87184,7 +87942,7 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ - ts.defaultPreferences = {}; + ts.emptyOptions = {}; var TextChange = /** @class */ (function () { function TextChange() { } @@ -87420,35 +88178,35 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 149 /* Parameter */: - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* 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 */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 272 /* CatchClause */: + case 265 /* JsxAttribute */: return 1 /* Value */; case 148 /* TypeParameter */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: case 166 /* TypeLiteral */: return 2 /* Type */; - case 298 /* JSDocTypedefTag */: + case 301 /* 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 273 /* EnumMember */: - case 235 /* ClassDeclaration */: + case 276 /* EnumMember */: + case 238 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -87458,26 +88216,26 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* EnumDeclaration */: - case 247 /* NamedImports */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 241 /* EnumDeclaration */: + case 250 /* NamedImports */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 249 /* ExportAssignment */) { + else if (node.parent.kind === 252 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -87510,7 +88268,7 @@ var ts; // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // 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 */; + return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { while (node.parent.kind === 146 /* QualifiedName */) { @@ -87536,16 +88294,16 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 185 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { + if (root.parent.kind === 187 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -87556,25 +88314,25 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return true; } switch (node.parent.kind) { case 162 /* TypeReference */: return true; - case 179 /* ImportType */: + case 181 /* ImportType */: return !node.parent.isTypeOf; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 189 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 190 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -87587,7 +88345,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -87612,11 +88370,11 @@ var ts; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -87628,20 +88386,20 @@ var ts; switch (node.parent.kind) { case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 273 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 276 /* EnumMember */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return node.parent.argumentExpression === node; case 147 /* ComputedPropertyName */: return true; - case 178 /* LiteralType */: - return node.parent.parent.kind === 176 /* IndexedAccessType */; + case 180 /* LiteralType */: + return node.parent.parent.kind === 178 /* IndexedAccessType */; default: return false; } @@ -87665,17 +88423,17 @@ var ts; return undefined; } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return node; } } @@ -87683,26 +88441,26 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return "class" /* classElement */; - case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 237 /* TypeAliasDeclaration */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 240 /* TypeAliasDeclaration */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 238 /* EnumDeclaration */: return "enum" /* enumElement */; - case 232 /* VariableDeclaration */: + case 241 /* EnumDeclaration */: return "enum" /* enumElement */; + case 235 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return "function" /* functionElement */; case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; @@ -87717,15 +88475,14 @@ var ts; 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 276 /* 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 */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: + case 249 /* NamespaceImport */: return "alias" /* alias */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -87749,11 +88506,13 @@ var ts; return "" /* unknown */; } } + case 71 /* Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; } function getKindOfVariableDeclaration(v) { - return ts.isConst(v) + return ts.isVarConst(v) ? "const" /* constElement */ : ts.isLet(v) ? "let" /* letElement */ @@ -87786,6 +88545,10 @@ var ts; return startEndContainsRange(r1.pos, r1.end, r2); } ts.rangeContainsRange = rangeContainsRange; + function rangeContainsRangeExclusive(r1, r2) { + return rangeContainsPositionExclusive(r1, r2.pos) && rangeContainsPositionExclusive(r1, r2.end); + } + ts.rangeContainsRangeExclusive = rangeContainsRangeExclusive; function rangeContainsPosition(r, pos) { return r.pos <= pos && pos <= r.end; } @@ -87806,6 +88569,10 @@ var ts; return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); } ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function nodeOverlapsWithStartEnd(node, sourceFile, start, end) { + return startEndOverlapsWithStartEnd(node.getStart(sourceFile), node.end, start, end); + } + ts.nodeOverlapsWithStartEnd = nodeOverlapsWithStartEnd; function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { var start = Math.max(start1, start2); var end = Math.min(end1, end2); @@ -87825,28 +88592,28 @@ var ts; return false; } switch (n.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: - case 180 /* ObjectBindingPattern */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: case 166 /* TypeLiteral */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 241 /* CaseBlock */: - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 244 /* CaseBlock */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 188 /* NewExpression */: + case 190 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 187 /* CallExpression */: - case 191 /* ParenthesizedExpression */: - case 173 /* ParenthesizedType */: + case 189 /* CallExpression */: + case 193 /* ParenthesizedExpression */: + case 175 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -87854,13 +88621,13 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 159 /* ConstructSignature */: case 158 /* CallSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -87870,19 +88637,19 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 183 /* ArrayLiteralExpression */: - case 181 /* ArrayBindingPattern */: - case 186 /* ElementAccessExpression */: + case 185 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 188 /* ElementAccessExpression */: case 147 /* ComputedPropertyName */: case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); @@ -87891,44 +88658,44 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 218 /* DoStatement */: + case 221 /* 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 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 195 /* TypeOfExpression */: - case 194 /* DeleteExpression */: - case 196 /* VoidExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: + case 197 /* TypeOfExpression */: + case 196 /* DeleteExpression */: + case 198 /* VoidExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -87992,38 +88759,30 @@ var ts; * position >= start and (position < end or (position === end && token is literal or keyword or identifier)) */ function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, /*includeJsDocComment*/ true, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); + return getTouchingToken(sourceFile, position, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); } ts.getTouchingPropertyName = getTouchingPropertyName; /** * Returns the token if position is in [start, end). * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true */ - function getTouchingToken(sourceFile, position, includeJsDocComment, includePrecedingTokenAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false, includeJsDocComment); + function getTouchingToken(sourceFile, position, includePrecedingTokenAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false); } 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); + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, /*includeEndPosition*/ false); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition, includeJsDocComment) { + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition) { var current = sourceFile; outer: while (true) { - if (ts.isToken(current)) { - // exit early - return current; - } // find the child that contains 'position' for (var _i = 0, _a = current.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; - if (!includeJsDocComment && ts.isJSDocNode(child)) { - continue; - } - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { // If this child begins after position, then all subsequent children will as well. break; @@ -88054,7 +88813,7 @@ var ts; function findTokenOnLeftOfPosition(file, position) { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. - var tokenAtPosition = getTokenAtPosition(file, position, /*includeJsDocComment*/ false); + var tokenAtPosition = getTokenAtPosition(file, position); if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } @@ -88068,19 +88827,14 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - var children = n.getChildren(); - for (var _i = 0, children_3 = children; _i < children_3.length; _i++) { - var child = children_3[_i]; + return ts.firstDefined(n.getChildren(), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || // previous token ends exactly at the beginning of child (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child, sourceFile)) { - return find(child); - } - } - return undefined; + return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find(child) : undefined; + }); } } ts.findNextToken = findNextToken; @@ -88088,7 +88842,7 @@ var ts; * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { + function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) { var result = find(startNode || sourceFile); ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; @@ -88105,7 +88859,7 @@ var ts; // we need to find the last token in a previous child. // 2) `position` is within the same span: we recurse on `child`. if (position < child.end) { - var start = child.getStart(sourceFile, includeJsDoc); + var start = child.getStart(sourceFile, /*includeJsDoc*/ !excludeJsdoc); var lookInPreviousChild = (start >= position) || // cursor in the leading trivia !nodeHasTokens(child, sourceFile) || isWhiteSpaceOnlyJsxText(child); @@ -88120,7 +88874,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 277 /* 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. @@ -88180,7 +88934,7 @@ var ts; * returns true if the position is in between the open and close elements of an JSX expression. */ function isInsideJsxElementOrAttribute(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); if (!token) { return false; } @@ -88192,17 +88946,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { return true; } return false; @@ -88212,7 +88966,7 @@ var ts; return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; } function isInTemplateString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; @@ -88254,7 +89008,7 @@ var ts; if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { - return { called: token, nTypeArguments: nTypeArguments }; + return ts.isDeclarationName(token) ? undefined : { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -88324,19 +89078,13 @@ var ts; * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - function isInComment(sourceFile, position, tokenAtPosition, predicate) { - return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); + function isInComment(sourceFile, position, tokenAtPosition) { + return ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*precedingToken*/ undefined, tokenAtPosition); } ts.isInComment = isInComment; function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*"; - } + var token = getTokenAtPosition(sourceFile, position); + return !!ts.findAncestor(token, ts.isJSDoc); } ts.hasDocComment = hasDocComment; function nodeHasTokens(n, sourceFile) { @@ -88345,7 +89093,7 @@ var ts; return n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node) { - var flags = ts.getCombinedModifierFlags(node); + var flags = ts.isDeclaration(node) ? ts.getCombinedModifierFlags(node) : 0 /* None */; var result = []; if (flags & 8 /* Private */) result.push("private" /* privateMemberModifier */); @@ -88365,10 +89113,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -88413,18 +89161,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 183 /* ArrayLiteralExpression */ || - node.kind === 184 /* ObjectLiteralExpression */) { + if (node.kind === 185 /* ArrayLiteralExpression */ || + node.kind === 186 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 200 /* BinaryExpression */ && + if (node.parent.kind === 202 /* 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 === 222 /* ForOfStatement */ && + if (node.parent.kind === 225 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -88432,7 +89180,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -88440,19 +89188,17 @@ var ts; } ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; function isInReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ true); } ts.isInReferenceComment = isInReferenceComment; function isInNonReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ false); } ts.isInNonReferenceComment = isInNonReferenceComment; + function isInReferenceCommentWorker(sourceFile, position, shouldBeReference) { + var range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined); + return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); + } function createTextSpanFromNode(node, sourceFile) { return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); } @@ -88566,13 +89312,17 @@ var ts; QuotePreference[QuotePreference["Single"] = 0] = "Single"; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); + function quotePreferenceFromString(str, sourceFile) { + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + } + ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference) { return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; } else { - var firstModuleSpecifier = ts.firstOrUndefined(sourceFile.imports); - return !!firstModuleSpecifier && !ts.isStringDoubleQuoted(firstModuleSpecifier, sourceFile) ? 0 /* Single */ : 1 /* Double */; + var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, ts.isStringLiteral); + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; } } ts.getQuotePreference = getQuotePreference; @@ -88652,6 +89402,37 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + var NodeMap = /** @class */ (function () { + function NodeMap() { + this.map = ts.createMap(); + } + NodeMap.prototype.get = function (node) { + var res = this.map.get(String(ts.getNodeId(node))); + return res && res.value; + }; + NodeMap.prototype.getOrUpdate = function (node, setValue) { + var res = this.get(node); + if (res) + return res; + var value = setValue(); + this.set(node, value); + return value; + }; + NodeMap.prototype.set = function (node, value) { + this.map.set(String(ts.getNodeId(node)), { node: node, value: value }); + }; + NodeMap.prototype.has = function (node) { + return this.map.has(String(ts.getNodeId(node))); + }; + NodeMap.prototype.forEach = function (cb) { + this.map.forEach(function (_a) { + var node = _a.node, value = _a.value; + return cb(value, node); + }); + }; + return NodeMap; + }()); + ts.NodeMap = NodeMap; function getParentNodeInSpan(node, file, span) { if (!node) return undefined; @@ -88667,6 +89448,10 @@ var ts; return ts.textSpanContainsPosition(span, node.getStart(file)) && node.getEnd() <= ts.textSpanEnd(span); } + function findModifier(node, kind) { + return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); + } + ts.findModifier = findModifier; /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); @@ -88879,7 +89664,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && + (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -89308,7 +90093,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_5 = dense[i + 1]; + var length_6 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -89317,8 +90102,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_5, classification: convertClassification(type) }); - lastEnd = start + length_5; + entries.push({ length: length_6, classification: convertClassification(type) }); + lastEnd = start + length_6; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -89497,10 +90282,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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -89712,18 +90497,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 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -89810,22 +90595,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -89854,17 +90639,17 @@ var ts; var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 232 /* VariableDeclaration */ || + if (parent.kind === 235 /* VariableDeclaration */ || parent.kind === 152 /* PropertyDeclaration */ || parent.kind === 149 /* Parameter */ || - parent.kind === 262 /* JsxAttribute */) { + parent.kind === 265 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 200 /* BinaryExpression */ || - parent.kind === 198 /* PrefixUnaryExpression */ || - parent.kind === 199 /* PostfixUnaryExpression */ || - parent.kind === 201 /* ConditionalExpression */) { + if (parent.kind === 202 /* BinaryExpression */ || + parent.kind === 200 /* PrefixUnaryExpression */ || + parent.kind === 201 /* PostfixUnaryExpression */ || + parent.kind === 203 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -89875,7 +90660,7 @@ var ts; } else if (tokenKind === 9 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -89891,7 +90676,7 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -89901,17 +90686,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -89963,12 +90748,12 @@ var ts; }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker)); + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; - function getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; + var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); @@ -89980,7 +90765,6 @@ var ts; } } else { - // Check for node modules return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } } @@ -90097,7 +90881,7 @@ var ts; for (var path in paths) { var patterns = paths[path]; if (paths.hasOwnProperty(path) && patterns) { - var _loop_13 = function (name, kind) { + var _loop_12 = function (name, kind) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind)); @@ -90105,7 +90889,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind; - _loop_13(name, kind); + _loop_12(name, kind); } } } @@ -90121,7 +90905,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_14 = function (moduleName) { + var _loop_13 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); @@ -90129,7 +90913,7 @@ var ts; }; for (var _e = 0, _f = enumerateNodeModulesVisibleToScript(host, scriptPath); _e < _f.length; _e++) { var moduleName = _f[_e]; - _loop_14(moduleName); + _loop_13(moduleName); } } if (!foundGlobal) { @@ -90146,14 +90930,16 @@ var ts; function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") && ts.startsWith(path, fragment) ? [{ name: path, kind: "directory" /* directory */ }] : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); - if (!ts.startsWith(fragment, pathPrefix)) { - return [{ name: pathPrefix, kind: "directory" /* directory */ }]; + var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); + return remainingFragment === undefined ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { + return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); + }); + function justPathMappingName(name) { + return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; } - var remainingFragment = fragment.slice(pathPrefix.length); - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { if (!host.readDirectory) { @@ -90210,7 +90996,7 @@ var ts; return nonRelativeModuleNames; } function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { - var token = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, position); var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); var range = commentRanges && ts.find(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end; }); if (!range) { @@ -90683,11 +91469,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.parent.parent.kind) { case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent)), isNewIdentifier: false }; - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -90695,12 +91481,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 179 /* ImportType */: + case 181 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 270 /* PropertyAssignment */: + case 273 /* 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 { @@ -90717,7 +91503,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -90730,8 +91516,8 @@ var ts; } return undefined; } - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -90740,9 +91526,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 254 /* ExternalModuleReference */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 257 /* 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*/"); @@ -90819,7 +91605,7 @@ var ts; || ts.codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) : symbol.name; } - function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, getCanonicalFileName, preferences, cancellationToken) { + function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); var name = entryId.name; @@ -90848,7 +91634,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; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -90891,14 +91677,14 @@ var ts; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, allSourceFiles, preferences) { + function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, allSourceFiles, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || symbolOriginInfo.type !== "export") { return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; 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; + var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, allSourceFiles, formatContext, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { @@ -90939,11 +91725,11 @@ var ts; return getContextualTypeFromParent(previousToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -90953,7 +91739,7 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo @@ -90968,15 +91754,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checker.getContextualType(parent); - case 200 /* BinaryExpression */: { + case 202 /* 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 266 /* CaseClause */: + case 269 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -90992,16 +91778,15 @@ 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 === 274 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); } 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 + var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) log("getCompletionData: Get current token: " + (ts.timestamp() - start)); start = ts.timestamp(); - // Completion not allowed inside comments, bail out if this is the case var insideComment = ts.isInComment(sourceFile, position, currentToken); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); var insideJsDocTagTypeExpression = false; @@ -91044,11 +91829,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { - currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 299 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 302 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -91066,7 +91851,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined); // 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 @@ -91075,7 +91860,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); // TODO: GH#18217 + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); } // Find the node where completion is requested on. @@ -91098,15 +91883,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; case 146 /* QualifiedName */: node = parent.left; break; - case 179 /* ImportType */: - case 210 /* MetaProperty */: + case 181 /* ImportType */: + case 212 /* MetaProperty */: node = parent; break; default: @@ -91119,7 +91904,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 === 185 /* PropertyAccessExpression */) { + if (parent && parent.kind === 187 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -91127,39 +91912,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 200 /* BinaryExpression */: - if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { - // It has a left-hand side, so we're not in an opening JSX tag. + case 202 /* BinaryExpression */: + if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: + case 260 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -91212,11 +91996,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: - case 294 /* JSDocReturnTag */: - case 296 /* JSDocTypeTag */: - case 298 /* JSDocTypedefTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: + case 297 /* JSDocReturnTag */: + case 299 /* JSDocTypeTag */: + case 301 /* JSDocTypedefTag */: return true; default: return false; @@ -91250,7 +92034,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -91274,27 +92058,31 @@ var ts; // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker, /*isForAccess*/ true)); + symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker)); } else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } } } function addPropertySymbol(symbol) { + // For a computed property with an accessible name like `Symbol.iterator`, + // we'll add a completion for the *name* `Symbol` instead of for the property. // 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 === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; - return leftName && typeChecker.getSymbolAtLocation(leftName); - }); - if (symbolSymbol) { - symbols.push(symbolSymbol); - symbolToOriginInfoMap[ts.getSymbolId(symbolSymbol)] = { type: "symbol-member" }; + var computedPropertyName = ts.firstDefined(symbol.declarations, function (decl) { return ts.tryCast(ts.getNameOfDeclaration(decl), ts.isComputedPropertyName); }); + if (computedPropertyName) { + var leftMostName = getLeftMostName(computedPropertyName.expression); // The completion is for `Symbol`, not `iterator`. + var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); + // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. + var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); + if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + symbols.push(firstAccessibleSymbol); + symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = { type: "symbol-member" }; + } } else { symbols.push(symbol); @@ -91378,10 +92166,10 @@ 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 !== 274 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { - for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { + for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { type: "this-type" }; symbols.push(symbol); @@ -91414,10 +92202,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 274 /* SourceFile */: - case 202 /* TemplateExpression */: - case 265 /* JsxExpression */: - case 213 /* Block */: + case 277 /* SourceFile */: + case 204 /* TemplateExpression */: + case 268 /* JsxExpression */: + case 216 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -91464,12 +92252,12 @@ var ts; return parentKind === 152 /* PropertyDeclaration */ || parentKind === 151 /* PropertySignature */ || parentKind === 149 /* Parameter */ || - parentKind === 232 /* VariableDeclaration */ || + parentKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 237 /* TypeAliasDeclaration */; + return parentKind === 240 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 208 /* AsExpression */; + return parentKind === 210 /* AsExpression */; } } return false; @@ -91572,11 +92360,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; + if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; } } return false; @@ -91586,36 +92374,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 187 /* CallExpression */ // func( a, | + return containingNodeKind === 189 /* 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 === 190 /* NewExpression */ // new C(a, | + || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 187 /* CallExpression */ // func( | + return containingNodeKind === 189 /* 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 */ + || containingNodeKind === 190 /* NewExpression */ // new C(a| + || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + return containingNodeKind === 185 /* 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 === 239 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 200 /* BinaryExpression */; // x = a| + return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 202 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: @@ -91653,16 +92441,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = hasIndexSignature(typeForObject); - typeMembers = getPropertiesForCompletion(typeForObject, typeChecker, /*isForAccess*/ false); + typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -91673,7 +92461,7 @@ 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 === 222 /* ForOfStatement */; + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 225 /* ForOfStatement */; if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); @@ -91720,7 +92508,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -91764,8 +92552,8 @@ 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); // TODO: GH#18217 - return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); + var type = typeChecker.getTypeAtLocation(baseTypeNode); + return type && typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); } @@ -91835,14 +92623,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: - case 263 /* JsxAttributes */: - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { + case 187 /* PropertyAccessExpression */: + case 266 /* JsxAttributes */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 262 /* JsxAttribute */) { + else if (parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91854,7 +92642,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 === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91864,8 +92652,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 265 /* JsxExpression */ && - parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { + parent.kind === 268 /* JsxExpression */ && + parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91873,7 +92661,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91893,49 +92681,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 232 /* VariableDeclaration */ || - containingNodeKind === 233 /* VariableDeclarationList */ || - containingNodeKind === 214 /* VariableStatement */ || - containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 235 /* VariableDeclaration */ || + containingNodeKind === 236 /* VariableDeclarationList */ || + containingNodeKind === 217 /* VariableStatement */ || + containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 182 /* BindingElement */; // var {x :html| + return containingNodeKind === 184 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 269 /* CatchClause */ || + return containingNodeKind === 272 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | - containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | + containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| + (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 248 /* ImportSpecifier */ || - containingNodeKind === 252 /* ExportSpecifier */ || - containingNodeKind === 246 /* NamespaceImport */; + return containingNodeKind === 251 /* ImportSpecifier */ || + containingNodeKind === 255 /* ExportSpecifier */ || + containingNodeKind === 249 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -92019,9 +92807,9 @@ 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 !== 270 /* PropertyAssignment */ && - m.kind !== 271 /* ShorthandPropertyAssignment */ && - m.kind !== 182 /* BindingElement */ && + if (m.kind !== 273 /* PropertyAssignment */ && + m.kind !== 274 /* ShorthandPropertyAssignment */ && + m.kind !== 184 /* BindingElement */ && m.kind !== 154 /* MethodDeclaration */ && m.kind !== 156 /* GetAccessor */ && m.kind !== 157 /* SetAccessor */) { @@ -92043,7 +92831,7 @@ var ts; // NOTE: if one only performs this step when m.name is an identifier, // things like '__proto__' are not filtered out. var name = ts.getNameOfDeclaration(m); - existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; + existingName = name && ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } @@ -92102,7 +92890,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 262 /* JsxAttribute */) { + if (attr.kind === 265 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -92209,47 +92997,28 @@ var ts; } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { - var jsDoc = getJsDocHavingNode(node).jsDoc; - if (!jsDoc) - return undefined; - for (var _i = 0, jsDoc_1 = jsDoc; _i < jsDoc_1.length; _i++) { - var _a = jsDoc_1[_i], pos = _a.pos, end = _a.end, tags = _a.tags; - if (!tags || position < pos || position > end) - continue; - for (var i = tags.length - 1; i >= 0; i--) { - var tag = tags[i]; - if (position >= tag.pos) { - return tag; - } - } - } + var jsdoc = ts.findAncestor(node, ts.isJSDoc); + return jsdoc && jsdoc.tags && (ts.rangeContainsPosition(jsdoc, position) ? ts.findLast(jsdoc.tags, function (tag) { return tag.pos < position; }) : undefined); } - function getJsDocHavingNode(node) { - if (!ts.isToken(node)) - return node; - switch (node.kind) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - // if the current token is var, let or const, skip the VariableDeclarationList - return node.parent.parent; - default: - return node.parent; - } + function getPropertiesForObjectExpression(contextualType, obj, checker) { + return contextualType.isUnion() + ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { + // 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. + return !(memberType.flags & 32764 /* Primitive */ || + checker.isArrayLikeType(memberType) || + ts.typeHasCallOrConstructSignatures(memberType, checker) || + checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); + })) + : contextualType.getApparentProperties(); } /** * Gets all properties on a type, but if that type is a union of several types, * excludes array-like types or callable/constructable types. */ - function getPropertiesForCompletion(type, checker, isForAccess) { - if (!(type.isUnion())) { - return ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); - } - // 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 & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); - }); - return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); + function getPropertiesForCompletion(type, checker) { + return type.isUnion() + ? ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") + : ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } /** * Returns the immediate owning class declaration of a context token, @@ -92258,7 +93027,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 300 /* SyntaxList */: + case 303 /* 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); @@ -92305,7 +93074,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -92314,12 +93083,16 @@ var ts; return ts.Debug.assertNever(triggerCharacter); } } + function binaryExpressionMayBeOpenTag(_a) { + var left = _a.left; + return ts.nodeIsMissing(left); + } function isStringLiteralOrTemplate(node) { switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: return true; default: return false; @@ -92453,7 +93226,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -92485,16 +93258,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 227 /* SwitchStatement */: - if (statement.kind === 223 /* ContinueStatement */) { + case 230 /* SwitchStatement */: + if (statement.kind === 226 /* ContinueStatement */) { return false; } // falls through - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -92504,24 +93277,17 @@ var ts; }); } function getModifierOccurrences(modifier, declaration) { - var modifierFlag = ts.modifierToFlag(modifier); - return ts.mapDefined(getNodesToSearchForModifier(declaration, modifierFlag), function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - var mod = ts.find(node.modifiers, function (m) { return m.kind === modifier; }); - ts.Debug.assert(!!mod); - return mod; - } - }); + return ts.mapDefined(getNodesToSearchForModifier(declaration, ts.modifierToFlag(modifier)), function (node) { return ts.findModifier(node, modifier); }); } function getNodesToSearchForModifier(declaration, modifierFlag) { // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: - case 213 /* Block */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: + case 216 /* Block */: + case 269 /* CaseClause */: + case 270 /* 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]); @@ -92531,10 +93297,10 @@ var ts; } case 155 /* Constructor */: case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -92567,7 +93333,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 === 218 /* DoStatement */) { + if (loopNode.kind === 221 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -92587,13 +93353,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -92965,12 +93731,13 @@ var ts; if (!markSeenDirectImport(direct)) { continue; } - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -92983,20 +93750,20 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -93006,7 +93773,7 @@ var ts; directImports.push(direct); } break; - case 179 /* ImportType */: + case 181 /* ImportType */: directImports.push(direct); break; default: @@ -93023,7 +93790,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -93078,7 +93845,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 243 /* ImportEqualsDeclaration */) { + if (decl.kind === 246 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -93088,7 +93855,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 179 /* ImportType */) { + if (decl.kind === 181 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -93103,17 +93870,17 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 250 /* ExportDeclaration */) { + if (decl.kind === 253 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -93163,7 +93930,7 @@ var ts; } } else { - var localSymbol = element.kind === 252 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 255 /* 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); @@ -93192,7 +93959,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 === 274 /* SourceFile */) { + if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -93222,7 +93989,8 @@ var ts; var map = ts.createMap(); for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { var sourceFile = sourceFiles_6[_i]; - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { @@ -93239,7 +94007,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 === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -93254,15 +94022,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: { + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -93286,7 +94054,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 185 /* PropertyAccessExpression */) { + if (parent.kind === 187 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -93408,10 +94176,10 @@ var ts; // 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 === 232 /* VariableDeclaration */) { + if (parent.kind === 235 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -93420,15 +94188,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 248 /* ImportSpecifier */: + case 251 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -93461,21 +94229,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 274 /* SourceFile */) { + if (parent.kind === 277 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -93510,13 +94278,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* 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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var result_6 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_6.push(nodeEntry(node)); }); return result_6; @@ -93532,8 +94300,7 @@ var ts; return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true }); } } - function findReferencedEntries(program, cancellationToken, sourceFiles, sourceFile, position, options) { - var node = ts.getTouchingPropertyName(sourceFile, position); + function findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options) { return ts.map(flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options)), toReferenceEntry); } FindAllReferences.findReferencedEntries = findReferencedEntries; @@ -93620,13 +94387,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 205 /* ClassExpression */) { + else if (node.kind === 207 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -93739,10 +94506,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 274 /* SourceFile */: + case 277 /* 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -93900,7 +94667,7 @@ var ts; this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; - /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ + /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { if (searchOptions === void 0) { searchOptions = {}; } // Note: if this is an external module symbol, the name doesn't include quotes. @@ -93983,6 +94750,24 @@ var ts; } } } + function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { + var importTracker = FindAllReferences.createImportTracker(sourceFiles, ts.arrayToSet(sourceFiles, function (f) { return f.fileName; }), checker, cancellationToken); + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers; + for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { + var importLocation = importSearches_2[_i][0]; + cb(importLocation); + } + for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) { + var indirectUser = indirectUsers_2[_b]; + for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { + var node = _d[_c]; + if (ts.isIdentifier(node) && checker.getSymbolAtLocation(node) === exportSymbol) { + cb(node); + } + } + } + } + Core.eachExportReference = eachExportReference; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; @@ -94015,9 +94800,9 @@ var ts; : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 184 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 182 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -94039,7 +94824,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 === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -94049,7 +94834,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, 235 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -94078,7 +94863,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 277 /* 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; @@ -94117,6 +94902,28 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function eachSignatureCall(signature, sourceFiles, checker, cb) { + if (!signature.name || !ts.isIdentifier(signature.name)) + return; + var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { + var name = _b[_a]; + if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) + continue; + var called = ts.climbPastPropertyAccess(name); + var call = called.parent; + if (!ts.isCallExpression(call) || call.expression !== called) + continue; + var referenceSymbol = checker.getSymbolAtLocation(name); + if (referenceSymbol && checker.getRootSymbols(referenceSymbol).some(function (s) { return s === symbol; })) { + cb(call); + } + } + } + } + Core.eachSignatureCall = eachSignatureCall; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos); }); @@ -94341,6 +95148,7 @@ var ts; function getReferenceForShorthandProperty(_a, search, state) { var flags = _a.flags, valueDeclaration = _a.valueDeclaration; var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + var name = valueDeclaration && ts.getNameOfDeclaration(valueDeclaration); /* * Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment * has two meanings: property name and property value. Therefore when we do findAllReference at the position where @@ -94348,8 +95156,8 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && search.includes(shorthandValueSymbol)) { - addReference(ts.getNameOfDeclaration(valueDeclaration), shorthandValueSymbol, state); + if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { @@ -94457,7 +95265,7 @@ var ts; if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -94477,7 +95285,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 213 /* Block */) { + if (body.kind === 216 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -94505,13 +95313,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 183 /* ArrayLiteralExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 185 /* ArrayLiteralExpression */: return true; default: return false; @@ -94609,20 +95417,20 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -94630,19 +95438,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* 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 274 /* SourceFile */: - return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); + case 277 /* SourceFile */: + return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -94844,16 +95652,17 @@ var ts; }); } ts.getEditsForFileRename = getEditsForFileRename; + // exported for tests function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var canonicalPath = getCanonicalFileName(path); - if (canonicalPath === canonicalOldPath) + if (getCanonicalFileName(path) === canonicalOldPath) return newFileOrDirPath; - var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + var suffix = ts.tryRemoveDirectoryPrefix(path, canonicalOldPath, getCanonicalFileName); return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; }; } + ts.getPathUpdater = getPathUpdater; function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) @@ -94924,9 +95733,10 @@ var ts; } } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { - var _loop_15 = function (sourceFile) { - var newFromOld = oldToNew(sourceFile.fileName); - var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.fileName; + var allFiles = program.getSourceFiles(); + var _loop_14 = function (sourceFile) { + var newFromOld = oldToNew(sourceFile.path); + var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.path; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); var oldFromNew = newToOld(sourceFile.fileName); var oldImportFromPath = oldFromNew || sourceFile.fileName; @@ -94939,20 +95749,24 @@ var ts; var newAbsolute = oldToNew(oldAbsolute); return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); }, function (importLiteral) { + var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + // No need to update if it's an ambient module^M + if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. // TODO:GH#18217 ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) - : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); - // If neither the importing source file nor the imported file moved, do nothing. - return toImport === undefined || !toImport.updated && !importingSourceFileMoved - ? undefined - : ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, preferences); + : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew); + // Need an update if the imported file moved, or the importing file moved and was using a relative path. + return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text))) + ? ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, allFiles, preferences) + : undefined; }); }; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - _loop_15(sourceFile); + for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { + var sourceFile = allFiles_1[_i]; + _loop_14(sourceFile); } } function combineNormal(pathA, pathB) { @@ -94961,12 +95775,10 @@ var ts; 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; + function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) { + if (importedModuleSymbol) { + // `find` should succeed because we checked for ambient modules before calling this function. + var oldFileName = ts.find(importedModuleSymbol.declarations, ts.isSourceFile).fileName; var newFileName = oldToNew(oldFileName); return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true }; } @@ -95042,7 +95854,8 @@ var ts; return getDefinitionInfoForIndexSignatures(node, typeChecker); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); - if (calledDeclaration) { + // Don't go to the component constructor definition for a JSX element, just go to the component definition. + if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && ts.isConstructorDeclaration(calledDeclaration))) { var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. @@ -95062,7 +95875,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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -95111,7 +95924,7 @@ var ts; */ function symbolMatchesSignature(s, calledDeclaration) { return s === calledDeclaration.symbol || s === calledDeclaration.symbol.parent || - ts.isVariableDeclaration(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; + !ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; } function getReferenceAtPosition(sourceFile, position, program) { var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); @@ -95204,11 +96017,11 @@ var ts; return true; } switch (declaration.kind) { - case 245 /* ImportClause */: - case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: return true; - case 248 /* ImportSpecifier */: - return declaration.parent.kind === 247 /* NamedImports */; + case 251 /* ImportSpecifier */: + return declaration.parent.kind === 250 /* NamedImports */; default: return false; } @@ -95262,7 +96075,7 @@ var ts; return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); } function findReferenceInPosition(refs, pos) { - return ts.find(refs, function (ref) { return ref.pos <= pos && pos <= ref.end; }); + return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; function getDefinitionInfoForFileReference(name, targetFileName) { @@ -95367,11 +96180,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: return [declaration]; - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -95392,16 +96205,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return withNode(tag.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -95531,7 +96344,7 @@ var ts; if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { return undefined; } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; @@ -95549,10 +96362,7 @@ var ts; var singleLineResult = "/** */"; return { newText: singleLineResult, caretOffset: 3 }; } - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - 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 indentationStr = getIndentationStringAtPosition(sourceFile, position); // 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) @@ -95560,8 +96370,7 @@ var ts; // * TODO: other tags. // * the closing comment line // * if the caret was directly in front of the object, then we add an extra line and indentation. - var preamble = "/**" + newLine + - indentationStr + " * "; + var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + @@ -95569,6 +96378,14 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function getIndentationStringAtPosition(sourceFile, position) { + var text = sourceFile.text; + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + var pos = lineStart; + for (; pos <= position && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) + ; + return text.slice(lineStart, pos); + } function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; @@ -95580,20 +96397,21 @@ var ts; function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: case 151 /* PropertySignature */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 237 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 240 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -95601,14 +96419,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 274 /* SourceFile */: + case 277 /* SourceFile */: return undefined; - case 239 /* ModuleDeclaration */: + case 242 /* 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 === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 200 /* BinaryExpression */: { + return commentOwner.parent.kind === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 202 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -95628,14 +96446,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return rightHandSide.parameters; - case 205 /* ClassExpression */: { + case 207 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -95654,7 +96472,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_16 = function (sourceFile) { + var _loop_15 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { return "continue"; @@ -95664,15 +96482,12 @@ 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_16(sourceFile); + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_15(sourceFile); } rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - return rawItems.map(createNavigateToItem); + return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } NavigateTo.getNavigateToItems = getNavigateToItems; function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { @@ -95687,23 +96502,23 @@ var ts; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 + // If the pattern has dots in it, then also see if the declaration container matches as well. + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } } else { - // If the pattern has dots in it, then also see if the declaration container matches as well. rawItems.push({ name: name, fileName: fileName, matchKind: match.kind, isCaseSensitive: match.isCaseSensitive, declaration: declaration }); } } } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 245 /* ImportClause */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - var importer = checker.getSymbolAtLocation(declaration.name); + case 248 /* ImportClause */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; default: @@ -95748,14 +96563,14 @@ 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 === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; + if (name && name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + return ts.emptyArray; } // Now, walk up our containers, adding all their names to the container array. var container = ts.getContainerNode(declaration); while (container) { if (!tryAddSingleDeclarationName(container, containers)) { - return undefined; + return ts.emptyArray; } container = ts.getContainerNode(container); } @@ -95780,7 +96595,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 */ // TODO: GH#18217 Just use `container ? ...` + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -95941,19 +96756,19 @@ var ts; addLeafNode(node); } break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addLeafNode(importClause); + addLeafNode(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -95964,8 +96779,8 @@ var ts; } } break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -95986,12 +96801,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -96001,9 +96816,9 @@ var ts; } endNode(); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -96011,18 +96826,18 @@ var ts; } endNode(); break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 252 /* ExportSpecifier */: - case 243 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: case 160 /* IndexSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -96030,7 +96845,7 @@ var ts; case 3 /* PrototypeProperty */: case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); - break; + return; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: @@ -96106,7 +96921,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -96116,7 +96931,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -96146,7 +96961,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -96154,16 +96969,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -96173,16 +96988,16 @@ var ts; } } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -96220,25 +97035,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 274 /* SourceFile */: - case 237 /* TypeAliasDeclaration */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 277 /* SourceFile */: + case 240 /* TypeAliasDeclaration */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return true; case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -96248,8 +97063,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; @@ -96260,7 +97075,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; + return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; }); } } @@ -96317,7 +97132,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 === 239 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -96328,16 +97143,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 === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 + return decl.body.kind === 242 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -96347,16 +97162,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 === 232 /* VariableDeclaration */) { + else if (node.parent.kind === 235 /* 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 === 200 /* BinaryExpression */ && + else if (node.parent.kind === 202 /* 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 === 270 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 273 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -96369,9 +97184,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: return true; default: return false; @@ -96427,10 +97242,7 @@ var ts; }); // Delete or replace the first import. if (newImportDecls.length === 0) { - changeTracker.deleteNode(sourceFile, oldImportDecls[0], { - useNonAdjustedStartPosition: true, - useNonAdjustedEndPosition: false, - }); + changeTracker.delete(sourceFile, oldImportDecls[0]); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. @@ -96442,7 +97254,7 @@ var ts; } // Delete any subsequent imports. for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + changeTracker.delete(sourceFile, oldImportDecls[i]); } } } @@ -96738,7 +97550,7 @@ var ts; var currentLineStart = lineStarts[i]; var lineEnd = i + 1 === lineStarts.length ? sourceFile.getEnd() : lineStarts[i + 1] - 1; var lineText = sourceFile.text.substring(currentLineStart, lineEnd); - var result = lineText.match(/^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/); + var result = isRegionDelimiter(lineText); if (!result || ts.isInComment(sourceFile, currentLineStart)) { continue; } @@ -96756,6 +97568,10 @@ var ts; } } } + var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + function isRegionDelimiter(lineText) { + return regionDelimiterRegExp.exec(lineText); + } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); if (!comments) @@ -96763,11 +97579,19 @@ var ts; var firstSingleLineCommentStart = -1; var lastSingleLineCommentEnd = -1; var singleLineCommentCount = 0; - for (var _i = 0, comments_3 = comments; _i < comments_3.length; _i++) { - var _a = comments_3[_i], kind = _a.kind, pos = _a.pos, end = _a.end; + var sourceText = sourceFile.getFullText(); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var _a = comments_2[_i], kind = _a.kind, pos = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { case 2 /* SingleLineCommentTrivia */: + // never fold region delimiters into single-line comment regions + var commentText = sourceText.slice(pos, end); + if (isRegionDelimiter(commentText)) { + combineAndAddMultipleSingleLineComments(); + singleLineCommentCount = 0; + break; + } // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (singleLineCommentCount === 0) { @@ -96798,24 +97622,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* 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 218 /* DoStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 269 /* CatchClause */: + case 221 /* DoStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 272 /* CatchClause */: return spanForNode(n.parent); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -96830,16 +97654,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanForNode(n.parent); - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 241 /* CaseBlock */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 244 /* CaseBlock */: return spanForNode(n); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -96913,7 +97737,6 @@ var ts; if (!candidateMatch) { return undefined; } - candidateContainers = candidateContainers || []; // -1 because the last part was checked against the name, and only the rest // of the parts are checked against the container. if (dotSeparatedSegments.length - 1 > candidateContainers.length) { @@ -97150,13 +97973,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_17 = 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_17(start); + var state_4 = _loop_16(start); if (typeof state_4 === "object") return state_4.value; } @@ -97672,21 +98495,12 @@ var ts; (function (ts) { var Rename; (function (Rename) { - function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); + function getRenameInfo(program, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }) : undefined; return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); - function isDefinedInLibraryFile(declaration) { - if (!defaultLibFileName) { - return false; - } - var sourceFile = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - return canonicalName === getCanonicalDefaultLibName(); - } } Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { @@ -97780,7 +98594,7 @@ var ts; InvocationKind[InvocationKind["Call"] = 0] = "Call"; InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; })(InvocationKind || (InvocationKind = {})); - function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { + function getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -97788,6 +98602,12 @@ var ts; // We are at the beginning of the file return undefined; } + if (shouldCarefullyCheckContext(triggerReason)) { + // In the middle of a string, don't provide signature help unless the user explicitly requested it. + if (ts.isInString(sourceFile, position, startingToken)) { + return undefined; + } + } var argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); if (!argumentInfo) return undefined; @@ -97806,6 +98626,10 @@ var ts; return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + function shouldCarefullyCheckContext(reason) { + // Only need to be careful if the user typed a character and signature help wasn't showing. + return !!reason && reason.kind === "characterTyped"; + } function getCandidateInfo(argumentInfo, checker) { var invocation = argumentInfo.invocation; if (invocation.kind === 0 /* Call */) { @@ -97828,11 +98652,11 @@ var ts; return undefined; } var typeChecker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_17 = function (sourceFile) { var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - var _loop_19 = function (declaration) { + var _loop_18 = function (declaration) { var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -97846,7 +98670,7 @@ var ts; }; for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { var declaration = declarations_13[_i]; - var state_6 = _loop_19(declaration); + var state_6 = _loop_18(declaration); if (typeof state_6 === "object") return state_6; } @@ -97854,7 +98678,7 @@ var ts; }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - var state_5 = _loop_18(sourceFile); + var state_5 = _loop_17(sourceFile); if (typeof state_5 === "object") return state_5.value; } @@ -97923,10 +98747,10 @@ var ts; return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -98075,7 +98899,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -98084,7 +98908,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - var _loop_20 = function (n) { + 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. ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); }); @@ -98094,7 +98918,7 @@ var ts; } }; for (var n = node; !ts.isBlock(n) && !ts.isSourceFile(n); n = n.parent) { - var state_7 = _loop_20(n); + var state_7 = _loop_19(n); if (typeof state_7 === "object") return state_7.value; } @@ -98239,7 +99063,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var decl = ts.getDeclarationOfJSInitializer(node); if (decl) { var symbol_3 = decl.symbol; @@ -98249,7 +99073,7 @@ var ts; } } // falls through if no diagnostic was created - case 234 /* FunctionDeclaration */: + case 237 /* 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)); @@ -98279,11 +99103,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); // TODO: GH#18217 - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -98300,12 +99124,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -98328,7 +99152,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -98373,7 +99197,7 @@ var ts; if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return "parameter" /* parameterElement */; } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { return "const" /* constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { @@ -98416,11 +99240,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 257 /* JsxOpeningElement */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -98460,7 +99284,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 185 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 187 /* 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)) { @@ -98481,7 +99305,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 190 /* 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 @@ -98568,7 +99392,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 207 /* 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 @@ -98602,7 +99426,7 @@ var ts; } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } @@ -98612,7 +99436,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -98650,7 +99474,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 237 /* TypeAliasDeclaration */) { + else if (declaration.kind === 240 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -98667,7 +99491,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 273 /* EnumMember */) { + if (declaration.kind === 276 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -98697,17 +99521,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 249 /* ExportAssignment */: + case 252 /* 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 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -98716,7 +99540,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 243 /* ImportEqualsDeclaration */) { + if (declaration.kind === 246 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -98794,10 +99618,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 === 274 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -98909,16 +99733,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 192 /* FunctionExpression */) { + if (declaration.kind === 194 /* FunctionExpression */) { return true; } - if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* FunctionDeclaration */) { + if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* 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 === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { + if (parent.kind === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { return false; } } @@ -99031,7 +99855,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_21 = function (opt) { + var _loop_20 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -99050,7 +99874,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_21(opt); + _loop_20(opt); } return options; } @@ -99227,10 +100051,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 262 /* JsxAttribute */: - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 265 /* JsxAttribute */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* 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 */; } @@ -99711,44 +100535,44 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 220 /* ForStatement */; + return context.contextNode.kind === 223 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 171 /* ConditionalType */: - case 208 /* AsExpression */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 173 /* ConditionalType */: + case 210 /* AsExpression */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 161 /* TypePredicate */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 182 /* BindingElement */: + case 184 /* BindingElement */: // equals in type X = ... - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: // equal in p = 0; case 149 /* Parameter */: - case 273 /* EnumMember */: + case 276 /* 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 221 /* ForInStatement */: + case 224 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] 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 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; @@ -99764,19 +100588,19 @@ var ts; return contextKind === 152 /* PropertyDeclaration */ || contextKind === 151 /* PropertySignature */ || contextKind === 149 /* Parameter */ || - contextKind === 232 /* VariableDeclaration */ || + contextKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 201 /* ConditionalExpression */ || - context.contextNode.kind === 171 /* ConditionalType */; + return context.contextNode.kind === 203 /* ConditionalExpression */ || + context.contextNode.kind === 173 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 180 /* ObjectBindingPattern */ || - context.contextNode.kind === 177 /* MappedType */ || + return context.contextNode.kind === 182 /* ObjectBindingPattern */ || + context.contextNode.kind === 179 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -99802,17 +100626,17 @@ var ts; return true; } switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 184 /* ObjectLiteralExpression */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 186 /* ObjectLiteralExpression */: + case 243 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -99820,13 +100644,13 @@ var ts; case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: case 158 /* CallSignature */: - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: case 155 /* Constructor */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -99835,40 +100659,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; + return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: case 166 /* TypeLiteral */: - case 239 /* ModuleDeclaration */: - case 250 /* ExportDeclaration */: - case 251 /* NamedExports */: - case 244 /* ImportDeclaration */: - case 247 /* NamedImports */: + case 242 /* ModuleDeclaration */: + case 253 /* ExportDeclaration */: + case 254 /* NamedExports */: + case 247 /* ImportDeclaration */: + case 250 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 269 /* CatchClause */: - case 240 /* ModuleBlock */: - case 227 /* SwitchStatement */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 272 /* CatchClause */: + case 243 /* ModuleBlock */: + case 230 /* SwitchStatement */: return true; - case 213 /* Block */: { + case 216 /* 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 !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { return true; } } @@ -99877,31 +100701,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - 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 */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 229 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 269 /* CatchClause */: + case 272 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 184 /* ObjectLiteralExpression */; + return context.contextNode.kind === 186 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 187 /* CallExpression */; + return context.contextNode.kind === 189 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 188 /* NewExpression */; + return context.contextNode.kind === 190 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -99913,28 +100737,28 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 193 /* ArrowFunction */; + return context.contextNode.kind === 195 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 179 /* ImportType */; + return context.contextNode.kind === 181 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; + return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; + return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 262 /* JsxAttribute */; + return context.nextTokenParent.kind === 265 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 262 /* JsxAttribute */; + return context.contextNode.kind === 265 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 256 /* JsxSelfClosingElement */; + return context.contextNode.kind === 259 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -99952,14 +100776,14 @@ var ts; return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 239 /* ModuleDeclaration */; + return context.contextNode.kind === 242 /* ModuleDeclaration */; } function isObjectTypeContext(context) { return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -99973,21 +100797,21 @@ var ts; } switch (parent.kind) { 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 192 /* TypeAssertionExpression */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -99998,16 +100822,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 190 /* TypeAssertionExpression */; + return context.contextNode.kind === 192 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 209 /* NonNullExpression */; + return context.contextNode.kind === 211 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -100241,17 +101065,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 274 /* SourceFile */: - case 213 /* Block */: - case 240 /* ModuleBlock */: + return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 277 /* SourceFile */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -100474,10 +101298,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - 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 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; case 156 /* GetAccessor */: return 125 /* GetKeyword */; case 157 /* SetAccessor */: return 136 /* SetKeyword */; case 154 /* MethodDeclaration */: @@ -100487,7 +101311,10 @@ var ts; // falls through case 152 /* PropertyDeclaration */: case 149 /* Parameter */: - return ts.getNameOfDeclaration(node).kind; + var name = ts.getNameOfDeclaration(node); + if (name) { + return name.kind; + } } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { @@ -100531,15 +101358,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 177 /* MappedType */) { + if (container.kind !== 179 /* MappedType */) { return false; } break; @@ -100639,7 +101466,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -101007,56 +101834,47 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword + tokenAtPosition) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } + var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); + if (jsdoc) + tokenAtPosition = jsdoc.parent; var tokenStart = tokenAtPosition.getStart(sourceFile); if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } - if (precedingToken === undefined) { - precedingToken = ts.findPrecedingToken(position, sourceFile); - } + precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); - var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? - trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : - trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; - if (commentRanges) { - for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { - var range = commentRanges_1[_i]; - // The end marker of a single-line comment does not include the newline character. - // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for closed multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // However, unterminated multi-line comments *do* contain their end. - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - // - if ((range.pos < position && position < range.end || - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()))) { - return (range.kind === 3 /* MultiLineCommentTrivia */ || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; - } - } - } - return undefined; + var commentRanges = ts.concatenate(trailingRangesOfPreviousToken, leadingCommentRangesOfNextToken); + return commentRanges && ts.find(commentRanges, function (range) { return ts.rangeContainsPositionExclusive(range, position) || + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -101064,8 +101882,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -101170,9 +101988,9 @@ var ts; if (options.indentStyle === ts.IndentStyle.None) { return 0; } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword - if (enclosingCommentRange) { + var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -101190,7 +102008,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* 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 */) { @@ -101346,7 +102164,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 === 274 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -101394,7 +102212,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -101412,13 +102230,13 @@ var ts; switch (node.parent.kind) { case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.parent.properties; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return node.parent.elements; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: @@ -101429,21 +102247,21 @@ var ts; return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 188 /* NewExpression */: - case 187 /* CallExpression */: { + case 190 /* NewExpression */: + case 189 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -101483,10 +102301,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: node = node.expression; break; default: @@ -101551,82 +102369,82 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - 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 219 /* ExpressionStatement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 185 /* ArrayLiteralExpression */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 177 /* MappedType */: + case 179 /* 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 244 /* CaseBlock */: + case 270 /* DefaultClause */: + case 269 /* CaseClause */: + case 193 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 217 /* VariableStatement */: + case 252 /* ExportAssignment */: + case 228 /* ReturnStatement */: + case 203 /* ConditionalExpression */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: + case 259 /* JsxSelfClosingElement */: + case 268 /* 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 175 /* ParenthesizedType */: + case 191 /* TaggedTemplateExpression */: + case 199 /* AwaitExpression */: + case 254 /* NamedExports */: + case 250 /* NamedImports */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 152 /* PropertyDeclaration */: return true; - case 232 /* VariableDeclaration */: - case 270 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 235 /* VariableDeclaration */: + case 273 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } 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 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: - case 193 /* ArrowFunction */: + case 195 /* 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 */: + return childKind !== 216 /* Block */; + case 253 /* ExportDeclaration */: + return childKind !== 254 /* NamedExports */; + case 247 /* ImportDeclaration */: + return childKind !== 248 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); + case 258 /* JsxElement */: + return childKind !== 261 /* JsxClosingElement */; + case 262 /* JsxFragment */: + return childKind !== 264 /* JsxClosingFragment */; + case 172 /* IntersectionType */: + case 171 /* UnionType */: if (childKind === 166 /* TypeLiteral */) { return false; } @@ -101638,17 +102456,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: { - if (parent.kind !== 213 /* Block */) { + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: { + if (parent.kind !== 216 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 194 /* FunctionExpression */ || grandParent.kind === 237 /* FunctionDeclaration */); } - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return true; default: return false; @@ -101777,7 +102595,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 === 184 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -101793,8 +102611,8 @@ var ts; this.formatContext = formatContext; this.changes = []; this.newFiles = []; - this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map + this.deletedNodes = []; } ChangeTracker.fromContext = function (context) { return new ChangeTracker(ts.getNewLineOrDefaultFromHost(context.host, context.formatContext.options), context.formatContext); @@ -101808,13 +102626,11 @@ var ts; this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); return this; }; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { - if (options === void 0) { options = {}; } - var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); - var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); - return this; + ChangeTracker.prototype.delete = function (sourceFile, node) { + this.deletedNodes.push({ sourceFile: sourceFile, node: node, }); + }; + ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { + this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } @@ -101829,30 +102645,6 @@ var ts; 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) { - ts.Debug.fail("node is not a list element"); - return this; - } - var index = ts.indexOfNode(containingList, node); - if (index < 0) { - return this; - } - if (containingList.length === 1) { - this.deleteNode(sourceFile, node); - return this; - } - // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. - // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. - ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice"); - this.deletedNodesInLists.add(node); - this.deleteRange(sourceFile, { - pos: startPositionToDeleteNodeInList(sourceFile, node), - end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), - }); - return this; - }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); @@ -101918,7 +102710,7 @@ var ts; // If so, we do not want to separate the node from its comment if we can. // Otherwise, add an extra new line immediately before the error span. var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); - var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); @@ -101942,7 +102734,7 @@ var ts; } } else { - endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -101961,6 +102753,9 @@ var ts; else if (ts.isParameter(before)) { return {}; } + else if (ts.isStringLiteral(before) && ts.isImportDeclaration(before.parent) || ts.isNamedImports(before)) { + return { suffix: ", " }; + } return ts.Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { @@ -102020,6 +102815,9 @@ var ts; var endPosition = this.insertNodeAfterWorker(sourceFile, after, newNode); this.insertNodeAt(sourceFile, endPosition, newNode, this.getInsertNodeAfterOptions(sourceFile, after)); }; + ChangeTracker.prototype.insertNodeAtEndOfList = function (sourceFile, list, newNode) { + this.insertNodeAt(sourceFile, list.end, newNode, { prefix: ", " }); + }; ChangeTracker.prototype.insertNodesAfter = function (sourceFile, after, newNodes) { var endPosition = this.insertNodeAfterWorker(sourceFile, after, ts.first(newNodes)); this.insertNodesAt(sourceFile, endPosition, newNodes, this.getInsertNodeAfterOptions(sourceFile, after)); @@ -102040,32 +102838,34 @@ var ts; return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { - if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) { - return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + switch (node.kind) { + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + case 235 /* VariableDeclaration */: + case 9 /* StringLiteral */: + case 71 /* Identifier */: + return { prefix: ", " }; + case 273 /* PropertyAssignment */: + return { suffix: "," + this.newLineCharacter }; + case 84 /* ExportKeyword */: + return { prefix: " " }; + case 149 /* Parameter */: + return {}; + default: + ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it + return { suffix: this.newLineCharacter }; } - else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { - return { suffix: this.newLineCharacter }; - } - else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { - return { prefix: ", " }; - } - else if (ts.isPropertyAssignment(node)) { - return { suffix: "," + this.newLineCharacter }; - } - else if (ts.isParameter(node)) { - return {}; - } - return ts.Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 193 /* ArrowFunction */) { + if (node.kind === 195 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); - this.deleteNode(sourceFile, arrow); + deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` @@ -102073,14 +102873,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 !== 213 /* Block */) { + if (node.body.kind !== 216 /* 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 === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -102106,7 +102906,7 @@ var ts; if (index !== containingList.length - 1) { // any element except the last one // use next sibling as an anchor - var nextToken = ts.getTokenAtPosition(sourceFile, after.end, /*includeJsDocComment*/ false); + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); if (nextToken && isSeparator(after, nextToken)) { // for list // a, b, c @@ -102211,14 +103011,25 @@ var ts; } }); }; - ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () { + ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - this.deletedNodesInLists.forEach(function (node) { + var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var _loop_21 = function (sourceFile, node) { + if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { + deleteDeclaration.deleteDeclaration(this_1, deletedNodesInLists, sourceFile, node); + } + }; + var this_1 = this; + for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { + var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; + _loop_21(sourceFile, node); + } + deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (node !== ts.last(list)) return; - var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2); + var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !deletedNodesInLists.has(n); }, list.length - 2); if (lastNonDeletedIndex !== -1) { _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) }); } @@ -102231,8 +103042,8 @@ var ts; * so we can only call this once and can't get the non-formatted text separately. */ ChangeTracker.prototype.getChanges = function (validate) { + this.finishDeleteDeclarations(); this.finishClassesWithNodesInsertedAtStart(); - this.finishTrailingCommaAfterDeletingNodesInList(); 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; @@ -102329,8 +103140,8 @@ var ts; })(changesToText || (changesToText = {})); function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { - var change = changes[i]; - text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + var _a = changes[i], span = _a.span, newText = _a.newText; + text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); } return text; } @@ -102532,6 +103343,177 @@ var ts; 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 `[` } + var deleteDeclaration; + (function (deleteDeclaration_1) { + function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { + switch (node.kind) { + case 149 /* Parameter */: { + var oldFunction = node.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, // 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. + ts.suppressLeadingAndTrailingTrivia(newFunction); + changes.replaceNode(sourceFile, oldFunction, newFunction); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 247 /* ImportDeclaration */: + deleteNode(changes, sourceFile, node, + // For first import, leave header comment in place + node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); + break; + case 184 /* BindingElement */: + var pattern = node.parent; + var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + if (preserveComma) { + deleteNode(changes, sourceFile, node); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 235 /* VariableDeclaration */: + deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); + break; + case 148 /* TypeParameter */: { + var typeParameters = ts.getEffectiveTypeParameterDeclarations(node.parent); + if (typeParameters.length === 1) { + var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; + var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1); + var nextToken = ts.getTokenAtPosition(sourceFile, end); + ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); + ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); + changes.deleteNodeRange(sourceFile, previousToken, nextToken); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 251 /* ImportSpecifier */: + var namedImports = node.parent; + if (namedImports.elements.length === 1) { + deleteImportBinding(changes, sourceFile, namedImports); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 249 /* NamespaceImport */: + deleteImportBinding(changes, sourceFile, node); + break; + default: + if (ts.isImportClause(node.parent) && node.parent.name === node) { + deleteDefaultImport(changes, sourceFile, node.parent); + } + else if (ts.isCallLikeExpression(node.parent)) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + else { + deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + } + } + } + deleteDeclaration_1.deleteDeclaration = deleteDeclaration; + function deleteDefaultImport(changes, sourceFile, importClause) { + if (!importClause.namedBindings) { + // Delete the whole import + deleteNode(changes, sourceFile, importClause.parent); + } + else { + // import |d,| * as ns from './file' + var start = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26 /* CommaToken */) { + // shift first non-whitespace position after comma to the start position of the node + var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); + changes.deleteRange(sourceFile, { pos: start, end: end }); + } + else { + deleteNode(changes, sourceFile, importClause.name); + } + } + } + function deleteImportBinding(changes, sourceFile, node) { + if (node.parent.name) { + // Delete named imports while preserving the default import + // import d|, * as ns| from './file' + // import d|, { a }| from './file' + var previousToken = ts.Debug.assertDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1)); + changes.deleteRange(sourceFile, { pos: previousToken.getStart(sourceFile), end: node.end }); + } + else { + // Delete the entire import declaration + // |import * as ns from './file'| + // |import { a } from './file'| + var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + deleteNode(changes, sourceFile, importDecl); + } + } + function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { + var parent = node.parent; + if (parent.kind === 272 /* CatchClause */) { + // TODO: There's currently no unused diagnostic for this, could be a suggestion + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + return; + } + if (parent.declarations.length !== 1) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + return; + } + var gp = parent.parent; + switch (gp.kind) { + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: + changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); + break; + case 223 /* ForStatement */: + deleteNode(changes, sourceFile, parent); + break; + case 217 /* VariableStatement */: + deleteNode(changes, sourceFile, gp); + break; + default: + ts.Debug.assertNever(gp); + } + } + })(deleteDeclaration || (deleteDeclaration = {})); + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + // Exported for tests only! (TODO: improve tests to not need this) + function deleteNode(changes, sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + changes.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + textChanges_3.deleteNode = deleteNode; + function deleteNodeInList(changes, deletedNodesInLists, sourceFile, node) { + var containingList = ts.Debug.assertDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile)); + var index = ts.indexOfNode(containingList, node); + ts.Debug.assert(index !== -1); + if (containingList.length === 1) { + deleteNode(changes, sourceFile, node); + return; + } + // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. + // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. + ts.Debug.assert(!deletedNodesInLists.has(node), "Deleting a node twice"); + deletedNodesInLists.add(node); + changes.deleteRange(sourceFile, { + pos: startPositionToDeleteNodeInList(sourceFile, node), + end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), + }); + } })(textChanges = ts.textChanges || (ts.textChanges = {})); })(ts || (ts = {})); /* @internal */ @@ -102587,15 +103569,14 @@ var ts; function createCombinedCodeActions(changes, commands) { return { changes: changes, commands: commands }; } + codefix.createCombinedCodeActions = createCombinedCodeActions; function createFileTextChanges(fileName, textChanges) { return { fileName: fileName, textChanges: textChanges }; } codefix.createFileTextChanges = createFileTextChanges; function codeFixAll(context, errorCodes, use) { var commands = []; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { - return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); - }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); }); return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } codefix.codeFixAll = codeFixAll; @@ -102608,6 +103589,7 @@ var ts; } } } + codefix.eachDiagnostic = eachDiagnostic; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -102658,7 +103640,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, }); function makeChange(changeTracker, sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var decorator = ts.findAncestor(token, ts.isDecorator); ts.Debug.assert(!!decorator, "Expected position to be owned by a decorator."); var replacement = ts.createCall(decorator.expression, /*typeArguments*/ undefined, /*argumentsArray*/ undefined); @@ -102690,7 +103672,7 @@ var ts; }); }, }); function getDeclaration(file, pos) { - var name = ts.getTokenAtPosition(file, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(file, pos); // For an arrow function with no name, 'name' lands on the first parameter. return ts.tryCast(ts.isParameter(name.parent) ? name.parent.parent : name.parent, parameterShouldGetTypeFromJSDoc); } @@ -102737,24 +103719,24 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 232 /* VariableDeclaration */ || + node.kind === 235 /* VariableDeclaration */ || node.kind === 151 /* PropertySignature */ || node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 162 /* TypeReference */: return transformJSDocTypeReference(node); @@ -102778,7 +103760,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 288 /* 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); @@ -102844,8 +103826,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, err) { return doChange(changes, err.file, err.start, context.program.getTypeChecker()); }); }, }); function doChange(changes, sourceFile, position, checker) { - var deletedNodes = []; - var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false)); + var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; @@ -102854,20 +103835,20 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); + changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { ts.copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 - deleteNode(precedingNode); + changes.delete(sourceFile, precedingNode); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + changes.delete(sourceFile, ctorDeclaration); } break; } @@ -102877,22 +103858,6 @@ var ts; ts.copyComments(ctorDeclaration, newClassDeclaration, sourceFile); // Because the preceding node could be touched, we need to insert nodes before delete nodes. changes.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration); - for (var _i = 0, deletedNodes_1 = deletedNodes; _i < deletedNodes_1.length; _i++) { - var _a = deletedNodes_1[_i], node = _a.node, inList = _a.inList; - if (inList) { - changes.deleteNodeInList(sourceFile, node); - } - else { - changes.deleteNode(sourceFile, node); - } - } - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - // If parent node has already been deleted, do nothing - if (!deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n.node); })) { - deletedNodes.push({ node: node, inList: inList }); - } - } function createClassElementsFromSymbol(symbol) { var memberElements = []; // all instance members are stored in the "member" array of symbol @@ -102930,15 +103895,15 @@ 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 === 216 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 219 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); + changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 192 /* FunctionExpression */: { + case 194 /* 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, @@ -102946,12 +103911,12 @@ var ts; ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 193 /* ArrowFunction */: { + case 195 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 213 /* Block */) { + if (arrowFunctionBody.kind === 216 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -102979,7 +103944,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { @@ -103043,10 +104008,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -103099,20 +104064,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 187 /* CallExpression */: { + case 189 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -103154,8 +104119,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: { + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -103178,7 +104143,7 @@ var ts; if (ts.isExportsOrModuleExportsOrAlias(sourceFile, left)) { if (ts.isExportsOrModuleExportsOrAlias(sourceFile, right)) { // `const alias = module.exports;` or `module.exports = alias;` can be removed. - changes.deleteNode(sourceFile, assignment.parent); + changes.delete(sourceFile, assignment.parent); } else { var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right) @@ -103209,10 +104174,10 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 271 /* ShorthandPropertyAssignment */: - case 272 /* SpreadAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 275 /* SpreadAssignment */: return undefined; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); @@ -103269,7 +104234,7 @@ var ts; changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); if (semi) - changes.deleteNode(sourceFile, semi, { useNonAdjustedEndPosition: true }); + changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` @@ -103280,7 +104245,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -103288,10 +104253,10 @@ var ts; } } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -103309,7 +104274,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: { + case 182 /* 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 @@ -103320,7 +104285,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 181 /* ArrayBindingPattern */: { + case 183 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -103403,11 +104368,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node; - case 182 /* BindingElement */: + case 184 /* BindingElement */: return parent.propertyName !== node; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -103466,7 +104431,7 @@ var ts; }); }, }); function getQualifiedName(sourceFile, pos) { - var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ true), ts.isQualifiedName); + var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), ts.isQualifiedName); ts.Debug.assert(!!qualifiedName, "Expected position to be owned by a qualified name."); return ts.isIdentifier(qualifiedName.left) ? qualifiedName : undefined; } @@ -103511,7 +104476,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -103539,7 +104504,7 @@ var ts; } } function getHeritageClauseSymbolTable(classDeclaration, checker) { - var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var heritageClauseNode = ts.getEffectiveBaseTypeNode(classDeclaration); if (!heritageClauseNode) return ts.createSymbolTable(); var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); @@ -103553,42 +104518,109 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var ChangeTracker = ts.textChanges.ChangeTracker; + codefix.importFixId = "fixMissingImport"; + var errorCodes = [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, + ts.Diagnostics.Cannot_find_namespace_0.code, + 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, + ]; codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics.Cannot_find_name_0.code, - ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, - ts.Diagnostics.Cannot_find_namespace_0.code, - 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: 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, + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span; + var info = getFixesInfo(context, errorCode, span.start); + if (!info) + return undefined; + var fixes = info.fixes, symbolName = info.symbolName; + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference); }); + }, + fixIds: [codefix.importFixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, preferences = context.preferences; + // Namespace fixes don't conflict, so just build a list. + var addToNamespace = []; + // Keys are import clause node IDs. + var addToExisting = ts.createMap(); + // Keys are module specifiers. + var newImports = ts.createMap(); + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getFixesInfo(context, diag.code, diag.start); + if (!info || !info.fixes.length) + return; + var fixes = info.fixes, symbolName = info.symbolName; + var fix = ts.first(fixes); + switch (fix.kind) { + case 0 /* UseNamespace */: + addToNamespace.push(fix); + break; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + var key = String(ts.getNodeId(importClause)); + var entry = addToExisting.get(key); + if (!entry) { + addToExisting.set(key, entry = { importClause: importClause, defaultImport: undefined, namedImports: [] }); + } + if (importKind === 0 /* Named */) { + ts.pushIfUnique(entry.namedImports, symbolName); + } + else { + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + } + break; + } + case 2 /* AddNew */: { + var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind; + var entry = newImports.get(moduleSpecifier); + if (!entry) { + newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined }); + } + switch (importKind) { + case 1 /* Default */: + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + break; + case 0 /* Named */: + ts.pushIfUnique(entry.namedImports, symbolName); + break; + case 3 /* Equals */: + case 2 /* Namespace */: + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; + break; + } + break; + } + default: + ts.Debug.assertNever(fix); + } + }); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) { + var fix = addToNamespace_1[_i]; + addNamespaceQualifier(changes, sourceFile, fix); + } + addToExisting.forEach(function (_a) { + var importClause = _a.importClause, defaultImport = _a.defaultImport, namedImports = _a.namedImports; + doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports); + }); + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + newImports.forEach(function (imports, moduleSpecifier) { + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports); + }); + })); + }, }); - function createCodeAction(descriptionDiagnostic, diagnosticArgs, changes) { - // TODO: GH#20315 - return codefix.createCodeFixActionNoFixId("import", changes, [descriptionDiagnostic].concat(diagnosticArgs)); - } - function convertToImportCodeFixContext(context, symbolToken, symbolName) { - var program = context.program; - var checker = program.getTypeChecker(); - return { - host: context.host, - formatContext: context.formatContext, - sourceFile: context.sourceFile, - program: program, - checker: checker, - compilerOptions: program.getCompilerOptions(), - getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), - symbolName: symbolName, - symbolToken: symbolToken, - preferences: context.preferences, - }; - } + // Sorted with the preferred fix coming first. + var ImportFixKind; + (function (ImportFixKind) { + ImportFixKind[ImportFixKind["UseNamespace"] = 0] = "UseNamespace"; + ImportFixKind[ImportFixKind["AddToExisting"] = 1] = "AddToExisting"; + ImportFixKind[ImportFixKind["AddNew"] = 2] = "AddNew"; + })(ImportFixKind || (ImportFixKind = {})); var ImportKind; (function (ImportKind) { ImportKind[ImportKind["Named"] = 0] = "Named"; @@ -103596,13 +104628,13 @@ var ts; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; })(ImportKind || (ImportKind = {})); - function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, symbolToken, preferences) { + function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, allSourceFiles, formatContext, symbolToken, preferences) { var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, checker, allSourceFiles); ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, exportInfos, host, preferences)).moduleSpecifier; - var ctx = { host: host, program: program, checker: checker, compilerOptions: compilerOptions, sourceFile: sourceFile, formatContext: formatContext, symbolName: symbolName, getCanonicalFileName: getCanonicalFileName, symbolToken: symbolToken, preferences: preferences }; - return { moduleSpecifier: moduleSpecifier, codeAction: ts.first(getCodeActionsForImport(exportInfos, ctx)) }; + var fix = ts.first(getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences)); + return { moduleSpecifier: moduleSpecifier, codeAction: codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences)) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, checker, allSourceFiles) { @@ -103622,23 +104654,16 @@ var ts; }); return result; } - function getCodeActionsForImport(exportInfos, context) { - var result = []; - getCodeActionsForImport_separateExistingAndNew(exportInfos, context, result, result); - return result; + function getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences) { + var checker = program.getTypeChecker(); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var useNamespace = tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker); + var addToExisting = tryAddToExistingImport(existingImports); + // Don't bother providing an action to add a new import if we can add to an existing one. + var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); + return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); } - function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - 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) { + function tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -103655,29 +104680,31 @@ var ts; 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); + var moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { + return { kind: 0 /* UseNamespace */, namespacePrefix: namespace.text, symbolToken: symbolToken }; } } }); } - function tryAddToExistingImport(existingImports, context) { + function tryAddToExistingImport(existingImports) { 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); - } - } + if (declaration.kind !== 247 /* ImportDeclaration */) + return undefined; + var importClause = declaration.importClause; + if (!importClause) + return undefined; + var name = importClause.name, namedBindings = importClause.namedBindings; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + ? { kind: 1 /* AddToExisting */, importClause: importClause, importKind: importKind } + : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 244 /* ImportDeclaration */) { + if (declaration.kind === 247 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -103688,141 +104715,61 @@ var ts; var imports = _b.imports; return ts.mapDefined(imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } - function getCodeActionForNewImport(context, _a) { - var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; - var sourceFile = context.sourceFile, symbolName = context.symbolName, preferences = context.preferences; - var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); - var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifierWithoutQuotes, ts.getQuotePreference(sourceFile, preferences)); - var importDecl = importKind !== 3 /* Equals */ - ? ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClauseOfKind(importKind, symbolName), quotedModuleSpecifier) - : ts.createImportEqualsDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createIdentifier(symbolName), ts.createExternalModuleReference(quotedModuleSpecifier)); - var changes = ChangeTracker.with(context, function (t) { return ts.insertImport(t, sourceFile, importDecl); }); - // 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 separating code and import statements. - return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); - } - function createImportClauseOfKind(kind, symbolName) { - var id = ts.createIdentifier(symbolName); - switch (kind) { - case 1 /* Default */: - return ts.createImportClause(id, /*namedBindings*/ undefined); - case 2 /* Namespace */: - return ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(id)); - case 0 /* Named */: - return ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, id)])); - default: - ts.Debug.assertNever(kind); - } - } function getNewImportInfos(program, sourceFile, moduleSymbols, host, preferences) { var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var modulePathsGroups = ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences); - return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); + return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ kind: 2 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); }); // 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, addNew) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); - var newImportInfos = existingDeclaration - ? [existingDeclaration] - : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.host, ctx.preferences); - for (var _i = 0, newImportInfos_1 = newImportInfos; _i < newImportInfos_1.length; _i++) { - var info = newImportInfos_1[_i]; - addNew.push(getCodeActionForNewImport(ctx, info)); - } + return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 244 /* ImportDeclaration */ + var expression = declaration.kind === 247 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; - return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; + return expression && ts.isStringLiteral(expression) ? { kind: 2 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; } - function tryUpdateExistingImport(context, importClause, importKind) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - var name = importClause.name; - var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 - switch (importKind) { - case 1 /* Default */: - return name ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(ts.createIdentifier(symbolName), namedBindings)); - }); - case 0 /* Named */: { - var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - 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 === 247 /* NamedImports */ && namedBindings.elements.length === 0) { - return ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); - }); - } - return undefined; - } - case 2 /* Namespace */: - return namedBindings ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamespaceImport(ts.createIdentifier(symbolName)))); - }); - case 3 /* Equals */: - return undefined; - default: - ts.Debug.assertNever(importKind); - } + function getFixesInfo(context, errorCode, pos) { + var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos); + var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getFixesInfoForUMDImport(context, symbolToken) + : getFixesInfoForNonUMDImport(context, symbolToken); + return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix, context, symbolToken) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - var changes = ChangeTracker.with(context, function (tracker) { - return tracker.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); - }); - return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); + function getFixesInfoForUMDImport(_a, token) { + var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; + var checker = program.getTypeChecker(); + var umdSymbol = getUmdSymbol(token, checker); + if (!umdSymbol) + return undefined; + var symbol = checker.getAliasedSymbol(umdSymbol); + var symbolName = umdSymbol.name; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()) }]; + var fixes = getFixForImport(exportInfos, symbolName, token, program, sourceFile, host, preferences); + return { fixes: fixes, symbolName: symbolName }; } - function getActionsForUMDImport(context) { - var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); - var checker = context.program.getTypeChecker(); - var umdSymbol; - if (ts.isIdentifier(token)) { - // try the identifier to see if it is the umd symbol - umdSymbol = checker.getSymbolAtLocation(token); - } - if (!ts.isUMDExportSymbol(umdSymbol)) { - // 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 === 260 /* JsxOpeningFragment */) { - umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); - } - } - if (ts.isUMDExportSymbol(umdSymbol)) { - var symbol = checker.getAliasedSymbol(umdSymbol); - if (symbol) { - return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(context.program.getCompilerOptions()) }], convertToImportCodeFixContext(context, token, umdSymbol.name)); - } - } - return undefined; + function getUmdSymbol(token, checker) { + // try the identifier to see if it is the umd symbol + var umdSymbol = ts.isIdentifier(token) ? checker.getSymbolAtLocation(token) : undefined; + if (ts.isUMDExportSymbol(umdSymbol)) + return umdSymbol; + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + var parent = token.parent; + return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67216319 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + : undefined; } function getUmdImportKind(compilerOptions) { // Import a synthetic `default` if enabled. @@ -103846,11 +104793,10 @@ var ts; return ts.Debug.assertNever(moduleKind); } } - function getActionsForNonUMDImport(context) { + function getFixesInfoForNonUMDImport(_a, symbolToken) { + var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. - var sourceFile = context.sourceFile, span = context.span, program = context.program, cancellationToken = context.cancellationToken; var checker = program.getTypeChecker(); - var symbolToken = ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false); // If we're at ``, we must check if `Foo` is already in scope, and if so, get an import for `React` instead. var symbolName = ts.isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken @@ -103860,14 +104806,14 @@ var ts; if (!symbolName) 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 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); + ts.Debug.assert(symbolName !== "default" /* Default */); + var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + var _ = _a[0], exportInfos = _a[1]; + return getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences); + })); + return { fixes: fixes, symbolName: symbolName }; } + // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, 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). @@ -103880,35 +104826,121 @@ var ts; // check the default export var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) { - var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); - if ((localSymbol && localSymbol.escapedName === symbolName || - getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target) === symbolName) && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { - addSymbol(moduleSymbol, localSymbol || defaultExport, 1 /* Default */); + var info = getDefaultExportInfo(defaultExport, moduleSymbol, program); + if (info && info.name === symbolName && symbolHasMeaning(info.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultExport, 1 /* Default */); } } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } - function getEscapedNameForExportDefault(symbol) { - return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { - if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.escapedText; - } - } - else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - return declaration.propertyName && declaration.propertyName.escapedText; - } - }); - } }); return originalSymbolToExportInfos; } - function checkSymbolHasMeaning(_a, meaning) { + function getDefaultExportInfo(defaultExport, moduleSymbol, program) { + var checker = program.getTypeChecker(); + var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) + return { symbolForMeaning: localSymbol, name: localSymbol.name }; + var name = getNameForExportDefault(defaultExport); + if (name !== undefined) + return { symbolForMeaning: defaultExport, name: name }; + if (defaultExport.flags & 2097152 /* Alias */) { + var aliased = checker.getAliasedSymbol(defaultExport); + return getDefaultExportInfo(aliased, ts.Debug.assertDefined(aliased.parent), program); + } + else { + var moduleName = moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target); + return moduleName === undefined ? undefined : { symbolForMeaning: defaultExport, name: moduleName }; + } + } + function getNameForExportDefault(symbol) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + if (ts.isExportAssignment(declaration)) { + if (ts.isIdentifier(declaration.expression)) { + return declaration.expression.text; + } + } + else if (ts.isExportSpecifier(declaration)) { + ts.Debug.assert(declaration.name.text === "default" /* Default */); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } + function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) { + var diag; + var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { + diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference); + }); + return codefix.createCodeFixAction("import", changes, diag, codefix.importFixId, ts.Diagnostics.Add_all_missing_imports); + } + function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) { + switch (fix.kind) { + case 0 /* UseNamespace */: + addNamespaceQualifier(changes, sourceFile, fix); + return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + doAddExistingFix(changes, sourceFile, importClause, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(importClause.parent.moduleSpecifier.getText()); + return [ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; + } + case 2 /* AddNew */: { + var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier; + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === 1 /* Default */ ? { defaultImport: symbolName, namedImports: ts.emptyArray, namespaceLikeImport: undefined } + : importKind === 0 /* Named */ ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined } + : { defaultImport: undefined, namedImports: ts.emptyArray, namespaceLikeImport: { importKind: importKind, name: symbolName } }); + return [ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; + } + default: + return ts.Debug.assertNever(fix); + } + } + function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { + if (defaultImport) { + ts.Debug.assert(!clause.name); + changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); + } + if (namedImports.length) { + var specifiers = namedImports.map(function (name) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); }); + if (clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements.length) { + for (var _i = 0, specifiers_1 = specifiers; _i < specifiers_1.length; _i++) { + var spec = specifiers_1[_i]; + changes.insertNodeInListAfter(sourceFile, ts.last(ts.cast(clause.namedBindings, ts.isNamedImports).elements), spec); + } + } + else { + if (specifiers.length) { + var namedImports_1 = ts.createNamedImports(specifiers); + if (clause.namedBindings) { + changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); + } + else { + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + } + } + } + } + } + function addNamespaceQualifier(changes, sourceFile, _a) { + var namespacePrefix = _a.namespacePrefix, symbolToken = _a.symbolToken; + changes.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); + } + function addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, _a) { + var defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport; + var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); + if (defaultImport !== undefined || namedImports.length) { + ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); + } + if (namespaceLikeImport) { + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ + ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) + : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + } + } + function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } @@ -104009,7 +105041,7 @@ var ts; // This is the identifier of the misspelled word. eg: // this.speling = 1; // ^^^^^^^ - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); // TODO: GH#15852 + var node = ts.getTokenAtPosition(sourceFile, pos); var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { @@ -104081,46 +105113,99 @@ var ts; var info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, context.preferences); + if (info.kind === InfoKind.enum) { + var token_1 = info.token, parentDeclaration_1 = info.parentDeclaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), token_1, parentDeclaration_1); }); + return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_missing_enum_member_0, token_1.text], fixId, ts.Diagnostics.Add_all_missing_members)]; + } + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); var addMember = inJs ? - ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, token.text, makeStatic)) : - getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, classDeclaration, token, makeStatic); + ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic)) : + getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, parentDeclaration, token, makeStatic); return ts.concatenate(ts.singleElementArray(methodCodeAction), addMember); }, fixIds: [fixId], getAllCodeActions: function (context) { - var seenNames = ts.createMap(); - return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var program = context.program, preferences = context.preferences; - var info = getInfo(diag.file, diag.start, program.getTypeChecker()); - if (!info) - return; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - if (!ts.addToSeen(seenNames, token.text)) { - return; - } - // Always prefer to add a method declaration if possible. - if (call) { - addMethodDeclaration(changes, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, preferences); - } - else { - if (inJs) { - addMissingMemberInJs(changes, classDeclarationSourceFile, classDeclaration, token.text, makeStatic); + var program = context.program, preferences = context.preferences; + var checker = program.getTypeChecker(); + var seen = ts.createMap(); + var classToMembers = new ts.NodeMap(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(diag.file, diag.start, checker); + if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { + return; + } + if (info.kind === InfoKind.enum) { + var token = info.token, parentDeclaration = info.parentDeclaration; + addEnumMemberDeclaration(changes, checker, token, parentDeclaration); } else { - var typeNode = getTypeNode(program.getTypeChecker(), classDeclaration, token); - addPropertyDeclaration(changes, classDeclarationSourceFile, classDeclaration, token.text, typeNode, makeStatic); + var parentDeclaration = info.parentDeclaration, token_2 = info.token; + var infos = classToMembers.getOrUpdate(parentDeclaration, function () { return []; }); + if (!infos.some(function (i) { return i.token.text === token_2.text; })) + infos.push(info); } - } - }); + }); + classToMembers.forEach(function (infos, classDeclaration) { + var superClasses = getAllSuperClasses(classDeclaration, checker); + var _loop_23 = function (info) { + // If some superclass added this property, don't add it again. + if (superClasses.some(function (superClass) { + var superInfos = classToMembers.get(superClass); + return !!superInfos && superInfos.some(function (_a) { + var token = _a.token; + return token.text === info.token.text; + }); + })) + return "continue"; + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + // Always prefer to add a method declaration if possible. + if (call) { + addMethodDeclaration(context, changes, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + } + else { + if (inJs) { + addMissingMemberInJs(changes, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic); + } + else { + var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token); + addPropertyDeclaration(changes, classDeclarationSourceFile, parentDeclaration, token.text, typeNode, makeStatic); + } + } + }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + _loop_23(info); + } + }); + })); }, }); + function getAllSuperClasses(cls, checker) { + var res = []; + while (cls) { + var superElement = ts.getClassExtendsHeritageElement(cls); + var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); + var superDecl = superSymbol && ts.find(superSymbol.declarations, ts.isClassLike); + if (superDecl) { + res.push(superDecl); + } + cls = superDecl; + } + return res; + } + var InfoKind; + (function (InfoKind) { + InfoKind[InfoKind["enum"] = 0] = "enum"; + InfoKind[InfoKind["class"] = 1] = "class"; + })(InfoKind || (InfoKind = {})); function getInfo(tokenSourceFile, tokenPos, checker) { // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ - var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos); if (!ts.isIdentifier(token)) { return undefined; } @@ -104129,14 +105214,21 @@ var ts; return undefined; var leftExpressionType = ts.skipConstraint(checker.getTypeAtLocation(parent.expression)); var symbol = leftExpressionType.symbol; - var classDeclaration = symbol && symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); - if (!classDeclaration) + if (!symbol || !symbol.declarations) return undefined; - var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); - var classDeclarationSourceFile = classDeclaration.getSourceFile(); - var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); - var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { token: token, classDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); + if (classDeclaration) { + var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); + var classDeclarationSourceFile = classDeclaration.getSourceFile(); + var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); + var call = ts.tryCast(parent.parent, ts.isCallExpression); + return { kind: InfoKind.class, token: token, parentDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + } + var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); + if (enumDeclaration) { + return { kind: InfoKind.enum, token: token, parentDeclaration: enumDeclaration }; + } + return undefined; } function getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic); }); @@ -104145,7 +105237,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 205 /* ClassExpression */) { + if (classDeclaration.kind === 207 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -104171,7 +105263,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 200 /* BinaryExpression */) { + if (token.parent.parent.kind === 202 /* 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))); // TODO: GH#18217 @@ -104225,11 +105317,11 @@ var ts; return codefix.createCodeFixActionNoFixId(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]); } function getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, token.text], fixId, ts.Diagnostics.Add_all_missing_members); } - function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); + function addMethodDeclaration(context, changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { + var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences); var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); @@ -104238,6 +105330,19 @@ var ts; changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); } } + function addEnumMemberDeclaration(changes, checker, token, enumDeclaration) { + /** + * create initializer only literal enum that has string initializer. + * value of initializer is a string literal that equal to name of enum member. + * numeric enum or empty enum will not create initializer. + */ + var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { + var type = checker.getTypeAtLocation(member); + return !!(type && type.flags & 68 /* StringLike */); + }); + var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); + changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104271,7 +105376,7 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function getTypesPackageNameToInstall(host, sourceFile, pos, diagCode) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), ts.isStringLiteral).text; + var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) @@ -104312,11 +105417,11 @@ var ts; function getClass(sourceFile, pos) { // Token is the identifier in the case of a class declaration // or the class keyword token in the case of a class expression. - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.cast(token.parent, ts.isClassLike); } function addMissingMembers(classDeclaration, sourceFile, checker, changeTracker, preferences) { - var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var extendsNode = ts.getEffectiveBaseTypeNode(classDeclaration); var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. @@ -104366,10 +105471,10 @@ var ts; }); function doChange(changes, sourceFile, constructor, superCall) { changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall); - changes.deleteNode(sourceFile, superCall); + changes.delete(sourceFile, superCall); } function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); if (token.kind !== 99 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); @@ -104408,7 +105513,7 @@ var ts; }); }, }); function getNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); return token.parent; } @@ -104444,7 +105549,7 @@ var ts; }); }, }); function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; @@ -104500,7 +105605,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos, diagCode) { - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(node)) return undefined; return { node: node, className: diagCode === didYouMeanStaticMemberCode ? ts.getContainingClass(node).name.text : undefined }; @@ -104534,25 +105639,30 @@ var ts; getCodeActions: function (context) { 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); + var sourceFiles = program.getSourceFiles(); + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var importDecl = tryGetFullImport(token); if (importDecl) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(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, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteFullDestructure(token, t, sourceFile, checker, sourceFiles, /*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); }); + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(sourceFile, token, t); }); 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, checker, /*isFixAll*/ false); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteDeclaration(sourceFile, token, t, checker, sourceFiles, /*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)); + var name = ts.isComputedPropertyName(token.parent) ? token.parent : token; + result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, name.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } var prefix = ts.textChanges.ChangeTracker.with(context, function (t) { return tryPrefixDeclaration(t, errorCode, sourceFile, token); }); if (prefix.length) { @@ -104562,32 +105672,28 @@ 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 ts.NodeSet(); var sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); + var sourceFiles = program.getSourceFiles(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); - var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); + var token = ts.getTokenAtPosition(sourceFile, diag.start); switch (context.fixId) { case fixIdPrefix: if (ts.isIdentifier(token) && canPrefix(token)) { tryPrefixDeclaration(changes, diag.code, sourceFile, token); } break; - case fixIdDelete: - // Ignore if this range was already deleted. - if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) - break; - var importDecl = tryGetFullImport(startToken); + case fixIdDelete: { + var importDecl = tryGetFullImport(token); if (importDecl) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } - else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && - !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); + else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(sourceFile, token, changes)) { + tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, /*isFixAll*/ true); } break; + } default: ts.Debug.fail(JSON.stringify(context.fixId)); } @@ -104595,49 +105701,29 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(startToken) { - return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; + function tryGetFullImport(token) { + return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { - if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) + function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { + if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; - var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; - switch (decl.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(decl, checker, isFixAll)) - break; - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNodeInList(sourceFile, decl); - break; - case 182 /* BindingElement */: - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNode(sourceFile, decl); - break; - default: - return ts.Debug.assertNever(decl); + var decl = token.parent.parent; + if (decl.kind === 149 /* Parameter */) { + tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); + } + else { + changes.delete(sourceFile, decl); } 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); + function tryDeleteFullVariableStatement(sourceFile, token, changes) { + var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { + changes.delete(sourceFile, declarationList.parent.kind === 217 /* 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; - return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token; - } function tryPrefixDeclaration(changes, errorCode, sourceFile, token) { // Don't offer to prefix a property. if (errorCode !== ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code && ts.isIdentifier(token) && canPrefix(token)) { @@ -104648,209 +105734,61 @@ var ts; switch (token.parent.kind) { case 149 /* Parameter */: return true; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { - tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll); + function tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, isFixAll) { + tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll); if (ts.isIdentifier(token)) deleteAssignments(changes, sourceFile, token, checker); } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 185 /* PropertyAccessExpression */) + if (ref.parent.kind === 187 /* PropertyAccessExpression */) ref = ref.parent; - if (ref.parent.kind === 200 /* BinaryExpression */ && ref.parent.parent.kind === 216 /* ExpressionStatement */) { - changes.deleteNode(sourceFile, ref.parent.parent); + if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + changes.delete(sourceFile, ref.parent.parent); } }); } - function tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { + function tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll) { var parent = token.parent; - switch (parent.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); - break; - 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; - var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false); - var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false); - ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); - ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); - changes.deleteNodeRange(sourceFile, previousToken, nextToken); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - 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, // 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. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 182 /* BindingElement */: { - var pattern = parent.parent; - var preserveComma = pattern.kind === 181 /* ArrayBindingPattern */ && parent !== ts.last(pattern.elements); - if (preserveComma) { - changes.deleteNode(sourceFile, parent); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - } - // handle case where 'import a = A;' - case 243 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(token, 243 /* ImportEqualsDeclaration */); - changes.deleteNode(sourceFile, importEquals); - break; - case 248 /* ImportSpecifier */: - var namedImports = parent.parent; - if (namedImports.elements.length === 1) { - tryDeleteNamedImportBinding(changes, sourceFile, namedImports); - } - else { - // delete import specifier - changes.deleteNodeInList(sourceFile, parent); - } - break; - 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, 244 /* ImportDeclaration */)); - } - else { - // import |d,| * as ns from './file' - var start = importClause.name.getStart(sourceFile); - var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end, /*includeJsDocComment*/ false); - if (nextToken && nextToken.kind === 26 /* CommaToken */) { - // shift first non-whitespace position after comma to the start position of the node - var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); - changes.deleteRange(sourceFile, { pos: start, end: end }); - } - else { - changes.deleteNode(sourceFile, importClause.name); - } - } - break; - case 246 /* NamespaceImport */: - tryDeleteNamedImportBinding(changes, sourceFile, parent); - break; - default: - if (ts.isDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent); - changes.deleteNode(sourceFile, token.parent); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent.parent); - changes.deleteNode(sourceFile, token.parent.parent); - } - break; - } - } - function tryDeleteNamedImportBinding(changes, sourceFile, namedBindings) { - if (namedBindings.parent.name) { - // Delete named imports while preserving the default import - // import d|, * as ns| from './file' - // import d|, { a }| from './file' - var previousToken = ts.getTokenAtPosition(sourceFile, namedBindings.pos - 1, /*includeJsDocComment*/ false); - if (previousToken && previousToken.kind === 26 /* CommaToken */) { - changes.deleteRange(sourceFile, { pos: previousToken.getStart(), end: namedBindings.end }); - } + if (ts.isParameter(parent)) { + tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, isFixAll); } else { - // Delete the entire import declaration - // |import * as ns from './file'| - // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); } } - // token.parent is a variableDeclaration - function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { - switch (varDecl.parent.parent.kind) { - case 220 /* ForStatement */: { - var forStatement = varDecl.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(forInitializer); - changes.deleteNode(sourceFile, forInitializer); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } - break; - } - case 222 /* ForOfStatement */: - var forOfStatement = varDecl.parent.parent; - 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 221 /* ForInStatement */: - case 230 /* TryStatement */: - break; - default: - var variableStatement = varDecl.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(variableStatement); - changes.deleteNode(sourceFile, variableStatement); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } + function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { + if (mayDeleteParameter(p, checker, isFixAll)) { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { case 154 /* MethodDeclaration */: - // Don't remove a parameter if this overrides something + // 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. + case 237 /* FunctionDeclaration */: + return true; + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: { + // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); @@ -104865,6 +105803,14 @@ var ts; return ts.Debug.failBadSyntaxKind(parent); } } + function deleteUnusedArguments(changes, sourceFile, deletedParameter, sourceFiles, checker) { + ts.FindAllReferences.Core.eachSignatureCall(deletedParameter.parent, sourceFiles, checker, function (call) { + var index = deletedParameter.parent.parameters.indexOf(deletedParameter); + if (call.arguments.length > index) { // Just in case the call didn't provide enough arguments. + changes.delete(sourceFile, call.arguments[index]); + } + }); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104884,12 +105830,12 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -104900,16 +105846,16 @@ var ts; break; } // falls through - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - changes.deleteNode(sourceFile, container); + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + changes.delete(sourceFile, container); break; default: if (ts.isBlock(statement.parent)) { split(sliceAfter(statement.parent.statements, statement), shouldRemove, function (start, end) { return changes.deleteNodeRange(sourceFile, start, end); }); } else { - changes.deleteNode(sourceFile, statement); + changes.delete(sourceFile, statement); } } } @@ -104921,12 +105867,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -104960,7 +105906,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var labeledStatement = ts.cast(token.parent, ts.isLabeledStatement); var pos = token.getStart(sourceFile); var statementPos = labeledStatement.statement.getStart(sourceFile); @@ -104990,7 +105936,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 281 /* JSDocNullableType */) { + if (typeNode.kind === 284 /* 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, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -105010,7 +105956,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -105019,7 +105965,7 @@ var ts; 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); + var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), isTypeContainer); var typeNode = decl && decl.type; return typeNode && { typeNode: typeNode, type: checker.getTypeFromTypeNode(typeNode) }; } @@ -105027,22 +105973,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 208 /* AsExpression */: + case 210 /* AsExpression */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 156 /* GetAccessor */: case 160 /* IndexSignature */: - case 177 /* MappedType */: + case 179 /* 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 */: + case 240 /* TypeAliasDeclaration */: + case 192 /* TypeAssertionExpression */: + case 235 /* VariableDeclaration */: return true; default: return false; @@ -105089,7 +106035,7 @@ var ts; } } function getNodes(sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var containingFunction = ts.getContainingFunction(token); if (!containingFunction) { return; @@ -105099,11 +106045,11 @@ var ts; case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -105273,8 +106219,22 @@ var ts; signatureDeclaration.body = body; return signatureDeclaration; } - function createMethodFromCallExpression(_a, methodName, inJs, makeStatic, preferences) { + function createMethodFromCallExpression(context, _a, methodName, inJs, makeStatic, preferences) { var typeArguments = _a.typeArguments, args = _a.arguments, parent = _a.parent; + var checker = context.program.getTypeChecker(); + var types = ts.map(args, function (arg) { + var type = checker.getTypeAtLocation(arg); + if (type === undefined) { + return undefined; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + type = checker.getBaseTypeOfLiteralType(type); + return checker.typeToTypeNode(type); + }); + var names = ts.map(args, function (arg) { + return ts.isIdentifier(arg) ? arg.text : + ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + }); return ts.createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, @@ -105283,11 +106243,11 @@ var ts; /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); }), - /*parameters*/ createDummyParameters(args.length, /*names*/ undefined, /*minArgumentCount*/ undefined, inJs), + /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), createStubbedMethodBody(preferences)); } codefix.createMethodFromCallExpression = createMethodFromCallExpression; - function createDummyParameters(argCount, names, minArgumentCount, inJs) { + function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; for (var i = 0; i < argCount; i++) { var newParameter = ts.createParameter( @@ -105296,7 +106256,7 @@ var ts; /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -105322,7 +106282,7 @@ var ts; } var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); - var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*inJs*/ false); + var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); var restParameter = ts.createParameter( @@ -105386,18 +106346,19 @@ var ts; if (ts.isSourceFileJavaScript(sourceFile)) { return undefined; // TODO: GH#20113 } - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var declaration; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeenseen*/ ts.returnTrue); }); - return changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getNameOfDeclaration(declaration).getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start, /*includeJsDocComment*/ false), err.code, program, cancellationToken, markSeen); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen); }); }, }); @@ -105479,11 +106440,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return !!declaration.name; } return false; @@ -105543,8 +106504,8 @@ var ts; function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? @@ -105612,21 +106573,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -105634,13 +106595,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 232 /* VariableDeclaration */: { + case 235 /* 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. @@ -105749,7 +106710,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -105777,7 +106738,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 187 /* CallExpression */) { + if (parent.kind === 189 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -105945,8 +106906,8 @@ 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 ? 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); }); + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -105973,7 +106934,7 @@ var ts; }); function getActionsForInvalidImportLocation(context) { var sourceFile = context.sourceFile; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -106048,7 +107009,7 @@ var ts; }, }); function getPropertyDeclaration(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined; } function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) { @@ -106133,7 +107094,7 @@ var ts; : ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, name, ts.createExternalModuleReference(required))); } function getInfo(sourceFile, pos) { - var parent = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false).parent; + var parent = ts.getTokenAtPosition(sourceFile, pos).parent; if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ true)) throw ts.Debug.failBadSyntaxKind(parent); var decl = ts.cast(parent.parent, ts.isVariableDeclaration); @@ -106166,7 +107127,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos) { - var name = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(name)) return undefined; // bad input var parent = name.parent; @@ -106190,7 +107151,7 @@ var ts; (function (codefix) { var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof"; var fixId = fixIdAddMissingTypeof; - var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code]; + var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { @@ -106205,9 +107166,9 @@ var ts; }); }, }); function getImportTypeNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 179 /* ImportType */); + ts.Debug.assert(token.parent.kind === 181 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -106243,7 +107204,7 @@ var ts; }); } }); function getInfo(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); if (ts.isClassDeclaration(indexSignature.parent)) return undefined; @@ -106272,129 +107233,325 @@ 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) + var refactorName = "Convert export"; + var actionNameDefaultToNamed = "Convert default export to named export"; + var actionNameNamedToDefault = "Convert named export to default export"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var info = getInfo(context); + if (!info) + return undefined; + var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; + var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + }, + }); + function getInfo(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var exportNode = ts.getParentNodeInSpan(token, file, span); + if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { + return undefined; + } + var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; + var flags = ts.getModifierFlags(exportNode); + var wasDefault = !!(flags & 512 /* Default */); + // If source file already has a default export, don't offer refactor. + if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + return undefined; + } + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: { + var node = exportNode; + return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + case 217 /* VariableStatement */: { + var vs = exportNode; + // Must be `export const x = something;`. + if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { 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 }; + } + var decl = ts.first(vs.declarationList.declarations); + if (!decl.initializer) + return undefined; + ts.Debug.assert(!wasDefault); + return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + default: + return undefined; + } + } + function doChange(exportingSourceFile, program, info, changes, cancellationToken) { + changeExport(exportingSourceFile, info, changes, program.getTypeChecker()); + changeImports(program, info, changes, cancellationToken); + } + function changeExport(exportingSourceFile, _a, changes, checker) { + var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; + if (wasDefault) { + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + } + else { + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + break; + case 217 /* VariableStatement */: + // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` + if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { + // We checked in `getInfo` that an initializer exists. + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + break; + } + // falls through + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: + // `export type T = number;` -> `type T = number; export default T;` + changes.deleteModifier(exportingSourceFile, exportKeyword); + changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); + break; + default: + ts.Debug.assertNever(exportNode); + } + } + } + function changeImports(program, _a, changes, cancellationToken) { + var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; + var checker = program.getTypeChecker(); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { + var importingSourceFile = ref.getSourceFile(); + if (wasDefault) { + changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text); + } + else { + changeNamedToDefaultImport(importingSourceFile, ref, changes); } }); - // 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())); + } + function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.default` --> `a.foo` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + // `default as foo` --> `foo`, `default as bar` --> `foo as bar` + changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); + break; } - 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; + case 248 /* ImportClause */: { + var clause = parent; + ts.Debug.assert(clause.name === ref); + var spec = makeImportSpecifier(exportName, ref.text); + var namedBindings = clause.namedBindings; + if (!namedBindings) { + // `import foo from "./a";` --> `import { foo } from "./a";` + changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); + } + else if (namedBindings.kind === 249 /* NamespaceImport */) { + // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` + changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); + changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } 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); + // `import foo, { bar } from "./a"` --> `import { bar, foo } from "./a";` + changes.delete(importingSourceFile, ref); + changes.insertNodeAtEndOfList(importingSourceFile, namedBindings.elements, spec); } - }); - // 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)); + break; } + default: + ts.Debug.failBadSyntaxKind(parent); } - 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_23 = 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))); - } + } + function changeNamedToDefaultImport(importingSourceFile, ref, changes) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.foo` --> `a.default` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + if (spec.kind === 251 /* ImportSpecifier */) { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(spec.name.text); + if (spec.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, spec.parent, defaultImport); } else { - changes.replaceNode(sourceFile, id, access); + changes.delete(importingSourceFile, spec); + changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); } - }); - }; - for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { - var element = _a[_i]; - _loop_23(element); + } + else { + // `export { foo } from "./a";` --> `export { default as foo } from "./a";` + // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` + // `export { foo as default } from "./a";` --> `export { default } from "./a";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + } + break; } - changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); - if (neededNamedImports.length) { - changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + default: + ts.Debug.failBadSyntaxKind(parent); + } + } + function makeImportSpecifier(propertyName, name) { + return ts.createImportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + function makeExportSpecifier(propertyName, name) { + return ts.createExportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + 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 === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 249 /* 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); + 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 === 249 /* 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)); } - function updateImport(old, defaultImportName, elements) { - return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + 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)); } - })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + 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_24 = 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_24(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); + } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); /* @internal */ @@ -106552,7 +107709,7 @@ 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 = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start), sourceFile, span); // Do the same for the ending position var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; @@ -106705,7 +107862,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 235 /* 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`! @@ -106717,13 +107874,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* 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 === 187 /* CallExpression */) { + if (node.parent.kind === 189 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -106738,8 +107895,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -106751,20 +107908,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 213 /* Block */: - if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { + case 216 /* Block */: + if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -106776,11 +107933,11 @@ var ts; break; } switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -106788,8 +107945,8 @@ var ts; seenLabels.pop(); break; } - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: { var label = node.label; if (label) { @@ -106799,20 +107956,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -106877,7 +108034,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 274 /* SourceFile */) { + if (current.kind === 277 /* SourceFile */) { return scopes; } } @@ -106969,12 +108126,12 @@ var ts; switch (scope.kind) { case 155 /* Constructor */: return "constructor"; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return "arrow function"; case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); @@ -106987,12 +108144,12 @@ var ts; } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 235 /* ClassDeclaration */ + return scope.kind === 238 /* 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 === 240 /* ModuleBlock */ + return scope.kind === 243 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -107271,7 +108428,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 216 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 219 /* 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( @@ -107290,9 +108447,9 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 216 /* ExpressionStatement */) { + if (node.parent.kind === 219 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. - changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); + changeTracker.delete(context.file, node.parent); } else { var localReference = ts.createIdentifier(localNameText); @@ -107377,7 +108534,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -107555,7 +108712,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 !== 234 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -107618,7 +108775,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_24 = function (i) { + var _loop_25 = 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 @@ -107658,7 +108815,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_24(i); + _loop_25(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -107871,30 +109028,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 273 /* EnumMember */: + case 276 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return parent.kind !== 244 /* ImportDeclaration */ && - parent.kind !== 248 /* ImportSpecifier */; - case 204 /* SpreadElement */: - case 180 /* ObjectBindingPattern */: - case 182 /* BindingElement */: + return parent.kind !== 247 /* ImportDeclaration */ && + parent.kind !== 251 /* ImportSpecifier */; + case 206 /* SpreadElement */: + case 182 /* ObjectBindingPattern */: + case 184 /* BindingElement */: return false; case 71 /* Identifier */: - return parent.kind !== 182 /* BindingElement */ && - parent.kind !== 248 /* ImportSpecifier */ && - parent.kind !== 252 /* ExportSpecifier */; + return parent.kind !== 184 /* BindingElement */ && + parent.kind !== 251 /* ImportSpecifier */ && + parent.kind !== 255 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 213 /* Block */: - case 274 /* SourceFile */: - case 240 /* ModuleBlock */: - case 266 /* CaseClause */: + case 216 /* Block */: + case 277 /* SourceFile */: + case 243 /* ModuleBlock */: + case 269 /* CaseClause */: return true; default: return false; @@ -107914,8 +109071,7 @@ var ts; var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { - var file = context.file; - if (!getConvertibleFieldAtPosition(context, file)) + if (!getConvertibleFieldAtPosition(context)) return undefined; return [{ name: actionName, @@ -107930,7 +109086,7 @@ var ts; } function getEditsForAction(context, _actionName) { var file = context.file; - var fieldInfo = getConvertibleFieldAtPosition(context, file); + var fieldInfo = getConvertibleFieldAtPosition(context); if (!fieldInfo) return undefined; var isJS = ts.isSourceFileJavaScript(file); @@ -107991,13 +109147,13 @@ var ts; function startsWithUnderscore(name) { return name.charCodeAt(0) === 95 /* _ */; } - function getConvertibleFieldAtPosition(context, file) { - var startPosition = context.startPosition, endPosition = context.endPosition; - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + function getConvertibleFieldAtPosition(context) { + var file = context.file, startPosition = context.startPosition, endPosition = context.endPosition; + var node = ts.getTokenAtPosition(file, startPosition); 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) // TODO: GH#18217 + if (!declaration || !ts.nodeOverlapsWithStartEnd(declaration.name, file, startPosition, endPosition) // TODO: GH#18217 || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; @@ -108152,11 +109308,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return true; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -108209,10 +109365,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_25 = function (sourceFile) { + var _loop_26 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_26 = function (statement) { + var _loop_27 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -108234,22 +109390,22 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_26(statement); + _loop_27(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_25(sourceFile); + _loop_26(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + case 247 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -108280,20 +109436,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -108363,15 +109519,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -108384,23 +109540,23 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } else { if (name && defaultUnused) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } if (namedBindings) { if (namedBindingsUnused) { - changes.deleteNode(sourceFile, namedBindings); + changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 247 /* NamedImports */) { + else if (namedBindings.kind === 250 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) - changes.deleteNodeInList(sourceFile, element); + changes.delete(sourceFile, element); } } } @@ -108411,20 +109567,20 @@ var ts; switch (name.kind) { case 71 /* Identifier */: if (isUnused(name)) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: break; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); + changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } else { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (ts.isIdentifier(element.name) && isUnused(element.name)) { - changes.deleteNode(sourceFile, element.name); + changes.delete(sourceFile, element.name); } } } @@ -108521,13 +109677,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: return true; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -108539,7 +109695,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -108549,9 +109705,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -108560,7 +109716,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -108572,9 +109728,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return name; - case 180 /* ObjectBindingPattern */: { + case 182 /* 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; @@ -108631,13 +109787,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -108645,17 +109801,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return cb(statement); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -108664,7 +109820,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -108696,23 +109852,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -108723,18 +109879,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -108809,7 +109965,7 @@ var ts; return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(file, startPosition); var func = ts.getContainingFunction(node); if (!func || !ts.isArrowFunction(func) || (!ts.rangeContainsRange(func, node) || ts.rangeContainsRange(func.body, node))) return undefined; @@ -108915,7 +110071,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 299 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 302 /* LastJSDocNode */; }); return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -108985,7 +110141,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(300 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(303 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -109042,7 +110198,7 @@ var ts; return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { - return ts.emptyArray; + return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -109296,7 +110452,7 @@ var ts; }; SourceFileObject.prototype.computeNamedDeclarations = function () { var result = ts.createMultiMap(); - ts.forEachChild(this, visit); + this.forEachChild(visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); @@ -109312,14 +110468,14 @@ var ts; return declarations; } function getDeclarationName(declaration) { - var name = ts.getNameOfDeclaration(declaration); + var name = ts.getNonAssignedNameOfDeclaration(declaration); return name && (ts.isComputedPropertyName(name) && ts.isPropertyAccessExpression(name.expression) ? name.expression.name.text : ts.isPropertyName(name) ? ts.getNameFromPropertyName(name) : undefined); } function visit(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: var functionDeclaration = node; @@ -109341,17 +110497,17 @@ var ts; } ts.forEachChild(node, visit); break; - 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 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 166 /* TypeLiteral */: @@ -109364,8 +110520,8 @@ var ts; break; } // falls through - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: { + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -109376,31 +110532,31 @@ var ts; } } // falls through - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: addDeclaration(node); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addDeclaration(importClause); + addDeclaration(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -109409,7 +110565,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -109777,7 +110933,7 @@ var ts; readFile: function (fileName) { // stub missing host functionality var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); if (entry) { return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot); } @@ -109827,7 +110983,7 @@ var ts; return; function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : (!!host.fileExists && host.fileExists(fileName)); @@ -109842,11 +110998,11 @@ var ts; return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); } function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { - ts.Debug.assert(hostCache !== undefined); + ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined // to the program to allow reporting of errors for missing files. - var hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path); + var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path); if (!hostFileInformation) { return undefined; } @@ -109942,17 +111098,17 @@ var ts; return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { - if (options === void 0) { options = ts.defaultPreferences; } + if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 - getCanonicalFileName, preferences, cancellationToken); + preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -109977,10 +111133,10 @@ var ts; return undefined; } // falls through - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_4 = typeChecker.getTypeAtLocation(node); @@ -110025,7 +111181,8 @@ var ts; 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]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; function scanForSourcemapURL(fileName) { var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); @@ -110034,11 +111191,15 @@ var ts; } var starts = ts.getLineStarts(mappedFile); for (var index = starts.length - 1; index >= 0; index--) { - sourceMapCommentRegExp.lastIndex = starts[index]; - var comment = sourceMapCommentRegExp.exec(mappedFile.text); + var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); + var comment = sourceMapCommentRegExp.exec(lineText); if (comment) { return comment[1]; } + // If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!lineText.match(whitespaceOrMapCommentRegExp)) { + break; + } } } function convertDocumentToSourceMapper(file, contents, mapFileName) { @@ -110192,18 +111353,32 @@ var ts; return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; + return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); }); + } + else { + var refs = getReferences(node, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + return refs && refs.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + return ({ fileName: fileName, textSpan: textSpan }); + }); + } } function getReferencesAtPosition(fileName, position) { - return getReferences(fileName, position); + synchronizeHostData(); + return getReferences(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position); } - function getReferences(fileName, position, options) { + function getReferences(node, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. 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); + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -110227,10 +111402,11 @@ var ts; /** * This is a semantic operation. */ - function getSignatureHelpItems(fileName, position) { + function getSignatureHelpItems(fileName, position, _a) { + var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); } /// Syntactic features function getNonBoundSourceFile(fileName) { @@ -110244,7 +111420,7 @@ var ts; return undefined; } switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: @@ -110252,7 +111428,7 @@ var ts; case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span @@ -110269,7 +111445,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 === 239 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 242 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -110339,7 +111515,7 @@ var ts; braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var token = ts.getTouchingToken(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, position); var matchKind = token.getStart(sourceFile) === position ? braceMatching.get(token.kind.toString()) : undefined; var match = matchKind && ts.findChildOfKind(token.parent, matchKind, sourceFile); // We want to order the braces when we return the result. @@ -110380,7 +111556,7 @@ var ts; return []; } function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = ts.createTextSpanFromBounds(start, end); @@ -110391,7 +111567,7 @@ var ts; }); } function getCombinedCodeFix(scope, fixId, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110399,7 +111575,7 @@ var ts; return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } function organizeImports(scope, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110407,7 +111583,7 @@ var ts; return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { @@ -110470,8 +111646,8 @@ var ts; } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); - return range && ts.createTextSpanFromRange(range); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); + return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -110599,8 +111775,7 @@ var ts; } function getRenameInfo(fileName, position) { synchronizeHostData(); - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - return ts.Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); + return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position); } function getRefactorContext(file, positionOrRange, preferences, formatOptions) { var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1]; @@ -110616,13 +111791,13 @@ var ts; }; } function getApplicableRefactors(fileName, positionOrRange, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getApplicableRefactors(getRefactorContext(file, positionOrRange, preferences)); } function getEditsForRefactor(fileName, formatOptions, positionOrRange, refactorName, actionName, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); @@ -110716,7 +111891,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 254 /* ExternalModuleReference */ || + node.parent.kind === 257 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -110734,7 +111909,7 @@ var ts; // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && + (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -110773,7 +111948,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 186 /* ElementAccessExpression */ && + node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -110804,7 +111979,7 @@ var ts; if (sourceFile.isDeclarationFile) { return undefined; } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { // Get previous token if the token is returned starts on new line @@ -110853,114 +112028,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return spanInVariableDeclaration(node); case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanInBlock(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInBlock(node.block); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 217 /* IfStatement */: + case 220 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return spanInForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 182 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 184 /* BindingElement */: // span on complete node return textSpan(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: // span in statement return spanInNode(node.statement); case 150 /* Decorator */: return spanInNodeArray(parent.decorators); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -111003,13 +112178,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 === 204 /* SpreadElement */ || - node.kind === 270 /* PropertyAssignment */ || - node.kind === 271 /* ShorthandPropertyAssignment */) && + node.kind === 206 /* SpreadElement */ || + node.kind === 273 /* PropertyAssignment */ || + node.kind === 274 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 200 /* BinaryExpression */) { + if (node.kind === 202 /* 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 @@ -111031,22 +112206,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: return textSpan(node); - case 200 /* BinaryExpression */: + case 202 /* 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 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -111055,20 +112230,20 @@ var ts; } } switch (node.parent.kind) { - case 270 /* PropertyAssignment */: + case 273 /* 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 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; @@ -111077,7 +112252,7 @@ var ts; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -111107,7 +112282,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -111119,7 +112294,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 222 /* ForOfStatement */) { + parent.parent.kind === 225 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -111160,7 +112335,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -111183,26 +112358,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 221 /* ForInStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 224 /* 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 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 236 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -111227,21 +112402,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 182 /* BindingElement */) { + if (bindingPattern.parent.kind === 184 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - 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; }); + ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); + var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -111249,18 +112424,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 === 200 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 202 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -111268,25 +112443,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 240 /* ModuleBlock */: + case 243 /* 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 238 /* EnumDeclaration */: - case 235 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -111294,7 +112469,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); @@ -111310,7 +112485,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 181 /* ArrayBindingPattern */: + case 183 /* 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); @@ -111325,12 +112500,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 187 /* CallExpression */ || - node.parent.kind === 188 /* NewExpression */) { + if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 189 /* CallExpression */ || + node.parent.kind === 190 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 191 /* ParenthesizedExpression */) { + if (node.parent.kind === 193 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -111339,21 +112514,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* 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 */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 193 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -111363,20 +112538,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 273 /* PropertyAssignment */ || node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 190 /* TypeAssertionExpression */) { + if (node.parent.kind === 192 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 218 /* DoStatement */) { + if (node.parent.kind === 221 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -111384,7 +112559,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.kind === 225 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -111804,9 +112979,9 @@ var ts; return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 7ad35c1c637..133c1e1ca95 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -242,144 +242,147 @@ declare namespace ts { 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, - JSDocThisTag = 295, - JSDocTypeTag = 296, - JSDocTemplateTag = 297, - JSDocTypedefTag = 298, - JSDocPropertyTag = 299, - SyntaxList = 300, - NotEmittedStatement = 301, - PartiallyEmittedExpression = 302, - CommaListExpression = 303, - MergeDeclarationMarker = 304, - EndOfDeclarationMarker = 305, - Count = 306, + OptionalType = 169, + RestType = 170, + UnionType = 171, + IntersectionType = 172, + ConditionalType = 173, + InferType = 174, + ParenthesizedType = 175, + ThisType = 176, + TypeOperator = 177, + IndexedAccessType = 178, + MappedType = 179, + LiteralType = 180, + ImportType = 181, + ObjectBindingPattern = 182, + ArrayBindingPattern = 183, + BindingElement = 184, + ArrayLiteralExpression = 185, + ObjectLiteralExpression = 186, + PropertyAccessExpression = 187, + ElementAccessExpression = 188, + CallExpression = 189, + NewExpression = 190, + TaggedTemplateExpression = 191, + TypeAssertionExpression = 192, + ParenthesizedExpression = 193, + FunctionExpression = 194, + ArrowFunction = 195, + DeleteExpression = 196, + TypeOfExpression = 197, + VoidExpression = 198, + AwaitExpression = 199, + PrefixUnaryExpression = 200, + PostfixUnaryExpression = 201, + BinaryExpression = 202, + ConditionalExpression = 203, + TemplateExpression = 204, + YieldExpression = 205, + SpreadElement = 206, + ClassExpression = 207, + OmittedExpression = 208, + ExpressionWithTypeArguments = 209, + AsExpression = 210, + NonNullExpression = 211, + MetaProperty = 212, + SyntheticExpression = 213, + TemplateSpan = 214, + SemicolonClassElement = 215, + Block = 216, + VariableStatement = 217, + EmptyStatement = 218, + ExpressionStatement = 219, + IfStatement = 220, + DoStatement = 221, + WhileStatement = 222, + ForStatement = 223, + ForInStatement = 224, + ForOfStatement = 225, + ContinueStatement = 226, + BreakStatement = 227, + ReturnStatement = 228, + WithStatement = 229, + SwitchStatement = 230, + LabeledStatement = 231, + ThrowStatement = 232, + TryStatement = 233, + DebuggerStatement = 234, + VariableDeclaration = 235, + VariableDeclarationList = 236, + FunctionDeclaration = 237, + ClassDeclaration = 238, + InterfaceDeclaration = 239, + TypeAliasDeclaration = 240, + EnumDeclaration = 241, + ModuleDeclaration = 242, + ModuleBlock = 243, + CaseBlock = 244, + NamespaceExportDeclaration = 245, + ImportEqualsDeclaration = 246, + ImportDeclaration = 247, + ImportClause = 248, + NamespaceImport = 249, + NamedImports = 250, + ImportSpecifier = 251, + ExportAssignment = 252, + ExportDeclaration = 253, + NamedExports = 254, + ExportSpecifier = 255, + MissingDeclaration = 256, + ExternalModuleReference = 257, + JsxElement = 258, + JsxSelfClosingElement = 259, + JsxOpeningElement = 260, + JsxClosingElement = 261, + JsxFragment = 262, + JsxOpeningFragment = 263, + JsxClosingFragment = 264, + JsxAttribute = 265, + JsxAttributes = 266, + JsxSpreadAttribute = 267, + JsxExpression = 268, + CaseClause = 269, + DefaultClause = 270, + HeritageClause = 271, + CatchClause = 272, + PropertyAssignment = 273, + ShorthandPropertyAssignment = 274, + SpreadAssignment = 275, + EnumMember = 276, + SourceFile = 277, + Bundle = 278, + UnparsedSource = 279, + InputFiles = 280, + JSDocTypeExpression = 281, + JSDocAllType = 282, + JSDocUnknownType = 283, + JSDocNullableType = 284, + JSDocNonNullableType = 285, + JSDocOptionalType = 286, + JSDocFunctionType = 287, + JSDocVariadicType = 288, + JSDocComment = 289, + JSDocTypeLiteral = 290, + JSDocSignature = 291, + JSDocTag = 292, + JSDocAugmentsTag = 293, + JSDocClassTag = 294, + JSDocCallbackTag = 295, + JSDocParameterTag = 296, + JSDocReturnTag = 297, + JSDocThisTag = 298, + JSDocTypeTag = 299, + JSDocTemplateTag = 300, + JSDocTypedefTag = 301, + JSDocPropertyTag = 302, + SyntaxList = 303, + NotEmittedStatement = 304, + PartiallyEmittedExpression = 305, + CommaListExpression = 306, + MergeDeclarationMarker = 307, + EndOfDeclarationMarker = 308, + Count = 309, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -391,7 +394,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 161, - LastTypeNode = 179, + LastTypeNode = 181, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -405,10 +408,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 146, - FirstJSDocNode = 278, - LastJSDocNode = 299, - FirstJSDocTagNode = 289, - LastJSDocTagNode = 299 + FirstJSDocNode = 281, + LastJSDocNode = 302, + FirstJSDocTagNode = 292, + LastJSDocTagNode = 302 } enum NodeFlags { None = 0, @@ -767,6 +770,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } + interface OptionalTypeNode extends TypeNode { + kind: SyntaxKind.OptionalType; + type: TypeNode; + } + interface RestTypeNode extends TypeNode { + kind: SyntaxKind.RestType; + type: TypeNode; + } type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; @@ -891,6 +902,11 @@ declare namespace ts { asteriskToken?: AsteriskToken; expression?: Expression; } + interface SyntheticExpression extends Expression { + kind: SyntaxKind.SyntheticExpression; + isSpread: boolean; + type: Type; + } type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; @@ -1105,7 +1121,10 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; } @@ -1780,6 +1799,7 @@ declare namespace ts { */ getTypeChecker(): TypeChecker; isSourceFileFromExternalLibrary(file: SourceFile): boolean; + isSourceFileDefaultLibrary(file: SourceFile): boolean; getProjectReferences(): (ResolvedProjectReference | undefined)[] | undefined; } interface ResolvedProjectReference { @@ -1818,7 +1838,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -1838,7 +1857,7 @@ declare namespace ts { getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1889,11 +1908,6 @@ declare namespace ts { typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): string; typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; @@ -1920,7 +1934,7 @@ declare namespace ts { getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined; + getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; @@ -1992,39 +2006,6 @@ declare namespace ts { AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8 } - /** - * @deprecated - */ - interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ - interface SymbolWriter extends SymbolTracker { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeProperty(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - } enum TypePredicateKind { This = 0, Identifier = 1 @@ -2214,7 +2195,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: Type[]; + aliasTypeArguments?: ReadonlyArray; } interface LiteralType extends Type { value: string | number; @@ -2279,10 +2260,18 @@ declare namespace ts { */ interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: Type[]; + typeArguments?: ReadonlyArray; } interface GenericType extends InterfaceType, TypeReference { } + interface TupleType extends GenericType { + minLength: number; + hasRestElement: boolean; + associatedNames?: __String[]; + } + interface TupleTypeReference extends TypeReference { + target: TupleType; + } interface UnionOrIntersectionType extends Type { types: Type[]; } @@ -2339,8 +2328,8 @@ declare namespace ts { } interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: TypeParameter[]; - parameters: Symbol[]; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; } enum IndexKind { String = 0, @@ -2388,14 +2377,14 @@ declare namespace ts { next?: DiagnosticMessageChain; } interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -2929,13 +2918,6 @@ declare namespace ts { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - /** @deprecated See comment on SymbolWriter */ - interface SymbolTracker { - trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError?(): void; - reportPrivateInBaseOfClassExpression?(propertyName: string): void; - reportInaccessibleUniqueSymbolError?(): void; - } interface TextSpan { start: number; length: number; @@ -3166,7 +3148,8 @@ declare namespace ts { function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; + function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; + function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** * Checks to see if the locale is in the appropriate format, @@ -3212,15 +3195,8 @@ declare namespace ts { function unescapeLeadingUnderscores(identifier: __String): string; function idText(identifier: Identifier): string; function symbolName(symbol: Symbol): string; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -3655,7 +3631,7 @@ declare namespace ts { /** Create a unique name based on the supplied text. This does not consider names injected by the transformer. */ function createFileLevelUniqueName(text: string): Identifier; /** Create a unique name generated for a node. */ - function getGeneratedNameForNode(node: Node): Identifier; + function getGeneratedNameForNode(node: Node | undefined): Identifier; function createToken(token: TKind): Token; function createSuper(): SuperExpression; function createThis(): ThisExpression & Token; @@ -3710,7 +3686,11 @@ declare namespace ts { function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTypleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; + function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; + function createRestTypeNode(type: TypeNode): RestTypeNode; + function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; @@ -3763,7 +3743,7 @@ declare namespace ts { 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; + /** @deprecated */ function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; @@ -3781,7 +3761,7 @@ declare namespace ts { function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): BinaryExpression; function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; - function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + /** @deprecated */ function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; @@ -3813,8 +3793,12 @@ declare namespace ts { function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; - function createStatement(expression: Expression): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createExpressionStatement(expression: Expression): ExpressionStatement; + function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + const createStatement: typeof createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + const updateStatement: typeof updateExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; @@ -4504,12 +4488,12 @@ declare namespace ts { */ interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** * One or more of the outputs of the project does not exist. @@ -4629,8 +4613,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; + getCallSignatures(): ReadonlyArray; + getConstructSignatures(): ReadonlyArray; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4771,7 +4755,7 @@ declare namespace ts { 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; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; @@ -4831,13 +4815,54 @@ declare namespace ts { type OrganizeImportsScope = CombinedCodeFixScope; type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } interface ApplyCodeActionCommandResult { successMessage: string; } @@ -5025,7 +5050,7 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index c1ead6a1fac..4785ced00f3 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -26,6 +26,33 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + 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; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; @@ -889,23 +916,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1866,8 +1876,9 @@ 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; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2207,160 +2218,163 @@ var ts; 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["OptionalType"] = 169] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; // Expression - 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["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; // Element - 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["Block"] = 216] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; // JSX - 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["JsxElement"] = 258] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; // The ? type - 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["JSDocThisTag"] = 295] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 296] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 297] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 298] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 299] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 296] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 297] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 298] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 299] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 300] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 301] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 302] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 300] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 303] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 301] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 302] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 303] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 304] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 305] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 304] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 305] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 306] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 307] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 308] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 306] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 309] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -2373,7 +2387,7 @@ var ts; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; @@ -2387,10 +2401,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 299] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 299] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 302] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 302] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -2564,6 +2578,7 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; @@ -2783,6 +2798,8 @@ var ts; CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; CheckFlags[CheckFlags["Late"] = 1024] = "Late"; CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped"; + CheckFlags[CheckFlags["OptionalParameter"] = 4096] = "OptionalParameter"; + CheckFlags[CheckFlags["RestParameter"] = 8192] = "RestParameter"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var InternalSymbolName; @@ -4417,6 +4434,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -4575,7 +4595,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -4695,6 +4714,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -4725,7 +4746,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -4795,6 +4816,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -4844,6 +4866,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -4991,6 +5014,9 @@ var ts; 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'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), 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."), @@ -5077,6 +5103,8 @@ var ts; 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}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), 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}'."), @@ -5376,6 +5404,10 @@ var ts; 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), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), 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}"), @@ -5407,6 +5439,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -5438,6 +5472,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -5582,6 +5617,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -7730,7 +7769,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274 /* SourceFile */) { + while (node && node.kind !== 277 /* SourceFile */) { node = node.parent; } return node; @@ -7738,11 +7777,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return true; } return false; @@ -7880,7 +7919,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 === 300 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 303 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7973,14 +8012,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { @@ -7994,7 +8025,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; + return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -8026,11 +8057,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 === 239 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 /* SourceFile */ || - node.kind === 239 /* ModuleDeclaration */ || + return node.kind === 277 /* SourceFile */ || + node.kind === 242 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8047,9 +8078,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 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node.parent); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8061,22 +8092,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 269 /* CatchClause */: - case 239 /* ModuleDeclaration */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 272 /* CatchClause */: + case 242 /* ModuleDeclaration */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; - case 213 /* Block */: + case 216 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8092,22 +8123,22 @@ var ts; 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 297 /* JSDocTemplateTag */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: - case 288 /* JSDocSignature */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 291 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -8117,8 +8148,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8127,15 +8158,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - 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 */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 217 /* VariableStatement */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -8156,7 +8187,7 @@ var ts; // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -8183,7 +8214,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8228,7 +8259,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213 /* Block */) { + if (node.body && node.body.kind === 216 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8242,7 +8273,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* 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 @@ -8251,25 +8282,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 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 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: errorNode = node.name; break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8301,35 +8332,34 @@ var ts; return file.scriptKind === 6 /* JSON */; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */ && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */) - || !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 /* ImportType */ && - n.argument.kind === 178 /* LiteralType */ && + return n.kind === 181 /* ImportType */ && + n.argument.kind === 180 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 /* ExpressionStatement */ + return node.kind === 219 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -8340,9 +8370,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 /* Parameter */ || node.kind === 148 /* TypeParameter */ || - node.kind === 192 /* FunctionExpression */ || - node.kind === 193 /* ArrowFunction */ || - node.kind === 191 /* ParenthesizedExpression */) ? + node.kind === 194 /* FunctionExpression */ || + node.kind === 195 /* ArrowFunction */ || + node.kind === 193 /* 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 '/**/' @@ -8358,7 +8388,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -8372,11 +8402,11 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 196 /* VoidExpression */; - case 207 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 198 /* VoidExpression */; + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148 /* TypeParameter */: - return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; + return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: @@ -8384,20 +8414,20 @@ var ts; if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 187 /* 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 === 146 /* QualifiedName */ || node.kind === 185 /* 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 === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through case 146 /* QualifiedName */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: { var parent = node.parent; if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 179 /* ImportType */) { + if (parent.kind === 181 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8406,22 +8436,22 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148 /* TypeParameter */: return node === parent.constraint; case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return node === parent.type; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -8432,12 +8462,12 @@ var ts; case 159 /* ConstructSignature */: case 160 /* IndexSignature */: return node === parent.type; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return node === parent.type; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8462,23 +8492,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitor(node); - 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 */: + case 244 /* CaseBlock */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8488,19 +8518,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -8543,12 +8573,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 166 /* TypeLiteral */: return node.members; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.properties; } } @@ -8556,14 +8586,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182 /* BindingElement */: - case 273 /* EnumMember */: + case 184 /* BindingElement */: + case 276 /* EnumMember */: case 149 /* Parameter */: - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 271 /* ShorthandPropertyAssignment */: - case 232 /* VariableDeclaration */: + case 274 /* ShorthandPropertyAssignment */: + case 235 /* VariableDeclaration */: return true; } } @@ -8575,12 +8605,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 /* VariableDeclarationList */ - && node.parent.parent.kind === 214 /* VariableStatement */; + return node.parent.kind === 236 /* VariableDeclarationList */ + && node.parent.parent.kind === 217 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -8592,8 +8622,8 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return true; } return false; @@ -8604,7 +8634,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228 /* LabeledStatement */) { + if (node.statement.kind !== 231 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -8612,17 +8642,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 184 /* ObjectLiteralExpression */ || - node.parent.kind === 205 /* ClassExpression */); + (node.parent.kind === 186 /* ObjectLiteralExpression */ || + node.parent.kind === 207 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8635,7 +8665,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270 /* PropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -8672,7 +8702,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274 /* SourceFile */); + ts.Debug.assert(node.kind !== 277 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -8707,14 +8737,14 @@ var ts; node = node.parent; } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 239 /* ModuleDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 242 /* ModuleDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 154 /* MethodDeclaration */: @@ -8725,8 +8755,8 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 238 /* EnumDeclaration */: - case 274 /* SourceFile */: + case 241 /* EnumDeclaration */: + case 277 /* SourceFile */: return node; } } @@ -8737,8 +8767,8 @@ var ts; if (container) { switch (container.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return container; } } @@ -8763,9 +8793,9 @@ var ts; case 147 /* ComputedPropertyName */: node = node.parent; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!stopOnFunctions) { continue; } @@ -8796,14 +8826,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { + if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 191 /* ParenthesizedExpression */) { + while (parent.kind === 193 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -8814,7 +8844,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -8823,7 +8853,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -8831,7 +8861,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -8844,10 +8874,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return node.tag; - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -8856,25 +8886,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // classes are valid targets return true; case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 235 /* ClassDeclaration */; + return parent.kind === 238 /* 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 === 235 /* ClassDeclaration */; + && parent.kind === 238 /* 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 === 155 /* Constructor */ || parent.kind === 154 /* MethodDeclaration */ || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 235 /* ClassDeclaration */; + && grandparent.kind === 238 /* ClassDeclaration */; } return false; } @@ -8890,7 +8920,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 case 154 /* MethodDeclaration */: case 157 /* SetAccessor */: @@ -8902,9 +8932,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 /* JsxOpeningElement */ || - parent.kind === 256 /* JsxSelfClosingElement */ || - parent.kind === 258 /* JsxClosingElement */) { + if (parent.kind === 260 /* JsxOpeningElement */ || + parent.kind === 259 /* JsxSelfClosingElement */ || + parent.kind === 261 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -8917,37 +8947,37 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - 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 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: + case 210 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 211 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 206 /* SpreadElement */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 206 /* OmittedExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 203 /* YieldExpression */: - case 197 /* AwaitExpression */: - case 210 /* MetaProperty */: + case 208 /* OmittedExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 205 /* YieldExpression */: + case 199 /* AwaitExpression */: + case 212 /* MetaProperty */: return true; case 146 /* QualifiedName */: while (node.parent.kind === 146 /* QualifiedName */) { @@ -8971,47 +9001,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 182 /* BindingElement */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 184 /* BindingElement */: return parent.initializer === node; - 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 */: + case 219 /* ExpressionStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 228 /* ReturnStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 232 /* ThrowStatement */: return parent.expression === node; - case 220 /* ForStatement */: + case 223 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forInStatement.expression === node; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return node === parent.expression; - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return node === parent.expression; case 147 /* ComputedPropertyName */: return node === parent.expression; case 150 /* Decorator */: - case 265 /* JsxExpression */: - case 264 /* JsxSpreadAttribute */: - case 272 /* SpreadAssignment */: + case 268 /* JsxExpression */: + case 267 /* JsxSpreadAttribute */: + case 275 /* SpreadAssignment */: return true; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -9019,7 +9049,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9028,7 +9058,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -9060,7 +9090,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187 /* CallExpression */) { + if (callExpression.kind !== 189 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -9156,11 +9186,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 192 /* FunctionExpression */ || - initializer.kind === 205 /* ClassExpression */ || - initializer.kind === 193 /* ArrowFunction */) { + if (initializer.kind === 194 /* FunctionExpression */ || + initializer.kind === 207 /* ClassExpression */ || + initializer.kind === 195 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9229,7 +9259,7 @@ var ts; return false; } function getRightMostAssignedExpression(node) { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -9252,6 +9282,14 @@ var ts; return 0 /* None */; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + // F.prototype = { ... } + return 6 /* Prototype */; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } @@ -9260,11 +9298,7 @@ var ts; return 2 /* ModuleExports */; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - // F.prototype = { ... } - return 6 /* Prototype */; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } @@ -9284,7 +9318,7 @@ var ts; } return 0 /* None */; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -9298,7 +9332,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9308,14 +9342,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.parent; - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return node.parent.parent; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return node.parent; - case 178 /* LiteralType */: + case 180 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9325,12 +9359,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.moduleSpecifier; - case 243 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 179 /* ImportType */: + case 246 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 181 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9339,11 +9373,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9351,7 +9385,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -9360,8 +9394,8 @@ var ts; case 149 /* Parameter */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 271 /* ShorthandPropertyAssignment */: - case 270 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return node.questionToken !== undefined; @@ -9371,14 +9405,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 /* JSDocFunctionType */ && + return node.kind === 287 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 301 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9403,12 +9437,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152 /* PropertyDeclaration */: return node.initializer; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return node.initializer; } } @@ -9418,59 +9452,57 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 /* ModuleDeclaration */ + node.body.kind === 242 /* ModuleDeclaration */ ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - 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. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } - } - // Pull parameter comments from declaring function as well - 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)) { - result = ts.addRange(result, node.initializer.jsDoc); - } + // Pull parameter comments from declaring function as well + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } + if (node.kind === 149 /* Parameter */) { + result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; + } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 /* PropertyAssignment */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + return parent; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -9519,7 +9551,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9532,31 +9564,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 191 /* ParenthesizedExpression */: - case 183 /* ArrayLiteralExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 185 /* ArrayLiteralExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: node = parent; break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -9583,22 +9615,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - 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 */: + case 216 /* Block */: + case 217 /* VariableStatement */: + case 229 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return true; } return false; @@ -9615,15 +9647,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173 /* ParenthesizedType */); + return walkUp(node, 175 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191 /* ParenthesizedExpression */); + return walkUp(node, 193 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */) { + while (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -9631,11 +9663,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 !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194 /* DeleteExpression */; + return node && node.kind === 196 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9692,9 +9724,9 @@ var ts; case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 185 /* PropertyAccessExpression */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 187 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; case 146 /* QualifiedName */: @@ -9706,12 +9738,12 @@ var ts; return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 182 /* BindingElement */: - case 248 /* ImportSpecifier */: + case 184 /* BindingElement */: + case 251 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 252 /* ExportSpecifier */: - case 262 /* JsxAttribute */: + case 255 /* ExportSpecifier */: + case 265 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -9727,13 +9759,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(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) || + return node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 245 /* NamespaceExportDeclaration */ || + node.kind === 248 /* ImportClause */ && !!node.name || + node.kind === 249 /* NamespaceImport */ || + node.kind === 251 /* ImportSpecifier */ || + node.kind === 255 /* ExportSpecifier */ || + node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9742,11 +9774,22 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + // Prefer an @augments tag because it may have type parameters. + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; @@ -9755,7 +9798,7 @@ var ts; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -9828,14 +9871,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -9849,9 +9892,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined @@ -9957,7 +10000,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182 /* BindingElement */) { + while (node.kind === 184 /* BindingElement */) { node = node.parent.parent; } return node; @@ -9966,14 +10009,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 /* Constructor */ - || kind === 192 /* FunctionExpression */ - || kind === 234 /* FunctionDeclaration */ - || kind === 193 /* ArrowFunction */ + || kind === 194 /* FunctionExpression */ + || kind === 237 /* FunctionDeclaration */ + || kind === 195 /* ArrowFunction */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ - || kind === 239 /* ModuleDeclaration */ - || kind === 274 /* SourceFile */; + || kind === 242 /* ModuleDeclaration */ + || kind === 277 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9992,23 +10035,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: return 1 /* Right */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -10032,15 +10075,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200 /* BinaryExpression */) { + if (expression.kind === 202 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { + else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10050,15 +10093,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return 0; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return 1; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return 2; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return 4; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -10079,21 +10122,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: return 16; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return 17; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return 18; - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 19 : 18; - case 189 /* TaggedTemplateExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 191 /* TaggedTemplateExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -10103,19 +10146,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - 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 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 191 /* ParenthesizedExpression */: - case 206 /* OmittedExpression */: + case 204 /* TemplateExpression */: + case 193 /* ParenthesizedExpression */: + case 208 /* OmittedExpression */: return 20; default: return -1; @@ -10174,6 +10217,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -10181,6 +10225,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -10603,7 +10664,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 289 /* 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); @@ -10615,7 +10676,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -10908,8 +10969,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 184 /* ObjectLiteralExpression */ - || kind === 183 /* ArrayLiteralExpression */; + return kind === 186 /* ObjectLiteralExpression */ + || kind === 185 /* ArrayLiteralExpression */; } return false; } @@ -10919,7 +10980,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */ + return node.kind === 209 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -10941,16 +11002,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); + (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 /* ObjectLiteralExpression */ && + return expression.kind === 186 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 /* ArrayLiteralExpression */ && + return expression.kind === 185 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11291,8 +11352,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11369,21 +11430,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 185 /* PropertyAccessExpression */: + case 187 /* 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 === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -11486,7 +11547,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -11556,6 +11617,11 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + /* @internal */ + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; // Returns true if 'span' contains 'other'. function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -11749,7 +11815,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { return current; } } @@ -11774,27 +11840,34 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232 /* VariableDeclaration */) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236 /* VariableDeclarationList */) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217 /* VariableStatement */) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags @@ -11804,19 +11877,7 @@ var ts; // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** @@ -11924,16 +11985,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -11950,17 +12001,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return expr.name; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11969,10 +12020,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 228 /* LabeledStatement */: { + case 231 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11984,7 +12035,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -11995,29 +12046,20 @@ 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; - } + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71 /* Identifier */: return declaration; - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: { + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -12029,17 +12071,22 @@ var ts; return undefined; } } - case 292 /* JSDocCallbackTag */: - return declaration.name; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -12328,545 +12375,545 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169 /* UnionType */; + return node.kind === 171 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170 /* IntersectionType */; + return node.kind === 172 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171 /* ConditionalType */; + return node.kind === 173 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172 /* InferType */; + return node.kind === 174 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173 /* ParenthesizedType */; + return node.kind === 175 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174 /* ThisType */; + return node.kind === 176 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175 /* TypeOperator */; + return node.kind === 177 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176 /* IndexedAccessType */; + return node.kind === 178 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177 /* MappedType */; + return node.kind === 179 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178 /* LiteralType */; + return node.kind === 180 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179 /* ImportType */; + return node.kind === 181 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 180 /* ObjectBindingPattern */; + return node.kind === 182 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181 /* ArrayBindingPattern */; + return node.kind === 183 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182 /* BindingElement */; + return node.kind === 184 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 183 /* ArrayLiteralExpression */; + return node.kind === 185 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184 /* ObjectLiteralExpression */; + return node.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185 /* PropertyAccessExpression */; + return node.kind === 187 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186 /* ElementAccessExpression */; + return node.kind === 188 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187 /* CallExpression */; + return node.kind === 189 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188 /* NewExpression */; + return node.kind === 190 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189 /* TaggedTemplateExpression */; + return node.kind === 191 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190 /* TypeAssertionExpression */; + return node.kind === 192 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191 /* ParenthesizedExpression */; + return node.kind === 193 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302 /* PartiallyEmittedExpression */) { + while (node.kind === 305 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192 /* FunctionExpression */; + return node.kind === 194 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193 /* ArrowFunction */; + return node.kind === 195 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194 /* DeleteExpression */; + return node.kind === 196 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195 /* TypeOfExpression */; + return node.kind === 197 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196 /* VoidExpression */; + return node.kind === 198 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197 /* AwaitExpression */; + return node.kind === 199 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198 /* PrefixUnaryExpression */; + return node.kind === 200 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199 /* PostfixUnaryExpression */; + return node.kind === 201 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200 /* BinaryExpression */; + return node.kind === 202 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201 /* ConditionalExpression */; + return node.kind === 203 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202 /* TemplateExpression */; + return node.kind === 204 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203 /* YieldExpression */; + return node.kind === 205 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204 /* SpreadElement */; + return node.kind === 206 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205 /* ClassExpression */; + return node.kind === 207 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206 /* OmittedExpression */; + return node.kind === 208 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208 /* AsExpression */; + return node.kind === 210 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209 /* NonNullExpression */; + return node.kind === 211 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210 /* MetaProperty */; + return node.kind === 212 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 211 /* TemplateSpan */; + return node.kind === 214 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212 /* SemicolonClassElement */; + return node.kind === 215 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 213 /* Block */; + return node.kind === 216 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214 /* VariableStatement */; + return node.kind === 217 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215 /* EmptyStatement */; + return node.kind === 218 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216 /* ExpressionStatement */; + return node.kind === 219 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217 /* IfStatement */; + return node.kind === 220 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218 /* DoStatement */; + return node.kind === 221 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219 /* WhileStatement */; + return node.kind === 222 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220 /* ForStatement */; + return node.kind === 223 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221 /* ForInStatement */; + return node.kind === 224 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222 /* ForOfStatement */; + return node.kind === 225 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223 /* ContinueStatement */; + return node.kind === 226 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224 /* BreakStatement */; + return node.kind === 227 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; + return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225 /* ReturnStatement */; + return node.kind === 228 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226 /* WithStatement */; + return node.kind === 229 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227 /* SwitchStatement */; + return node.kind === 230 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228 /* LabeledStatement */; + return node.kind === 231 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229 /* ThrowStatement */; + return node.kind === 232 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230 /* TryStatement */; + return node.kind === 233 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231 /* DebuggerStatement */; + return node.kind === 234 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232 /* VariableDeclaration */; + return node.kind === 235 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233 /* VariableDeclarationList */; + return node.kind === 236 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234 /* FunctionDeclaration */; + return node.kind === 237 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235 /* ClassDeclaration */; + return node.kind === 238 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236 /* InterfaceDeclaration */; + return node.kind === 239 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237 /* TypeAliasDeclaration */; + return node.kind === 240 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */; + return node.kind === 241 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */; + return node.kind === 242 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240 /* ModuleBlock */; + return node.kind === 243 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241 /* CaseBlock */; + return node.kind === 244 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242 /* NamespaceExportDeclaration */; + return node.kind === 245 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */; + return node.kind === 246 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244 /* ImportDeclaration */; + return node.kind === 247 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245 /* ImportClause */; + return node.kind === 248 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246 /* NamespaceImport */; + return node.kind === 249 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247 /* NamedImports */; + return node.kind === 250 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248 /* ImportSpecifier */; + return node.kind === 251 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249 /* ExportAssignment */; + return node.kind === 252 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250 /* ExportDeclaration */; + return node.kind === 253 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251 /* NamedExports */; + return node.kind === 254 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252 /* ExportSpecifier */; + return node.kind === 255 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253 /* MissingDeclaration */; + return node.kind === 256 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 254 /* ExternalModuleReference */; + return node.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 255 /* JsxElement */; + return node.kind === 258 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256 /* JsxSelfClosingElement */; + return node.kind === 259 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257 /* JsxOpeningElement */; + return node.kind === 260 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258 /* JsxClosingElement */; + return node.kind === 261 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259 /* JsxFragment */; + return node.kind === 262 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260 /* JsxOpeningFragment */; + return node.kind === 263 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261 /* JsxClosingFragment */; + return node.kind === 264 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262 /* JsxAttribute */; + return node.kind === 265 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263 /* JsxAttributes */; + return node.kind === 266 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264 /* JsxSpreadAttribute */; + return node.kind === 267 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265 /* JsxExpression */; + return node.kind === 268 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 266 /* CaseClause */; + return node.kind === 269 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267 /* DefaultClause */; + return node.kind === 270 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268 /* HeritageClause */; + return node.kind === 271 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269 /* CatchClause */; + return node.kind === 272 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 270 /* PropertyAssignment */; + return node.kind === 273 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271 /* ShorthandPropertyAssignment */; + return node.kind === 274 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272 /* SpreadAssignment */; + return node.kind === 275 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 274 /* SourceFile */; + return node.kind === 277 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275 /* Bundle */; + return node.kind === 278 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276 /* UnparsedSource */; + return node.kind === 279 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 278 /* JSDocTypeExpression */; + return node.kind === 281 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279 /* JSDocAllType */; + return node.kind === 282 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280 /* JSDocUnknownType */; + return node.kind === 283 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281 /* JSDocNullableType */; + return node.kind === 284 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282 /* JSDocNonNullableType */; + return node.kind === 285 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283 /* JSDocOptionalType */; + return node.kind === 286 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284 /* JSDocFunctionType */; + return node.kind === 287 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285 /* JSDocVariadicType */; + return node.kind === 288 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286 /* JSDocComment */; + return node.kind === 289 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290 /* JSDocAugmentsTag */; + return node.kind === 293 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291 /* JSDocClassTag */; + return node.kind === 294 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295 /* JSDocThisTag */; + return node.kind === 298 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293 /* JSDocParameterTag */; + return node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294 /* JSDocReturnTag */; + return node.kind === 297 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296 /* JSDocTypeTag */; + return node.kind === 299 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297 /* JSDocTemplateTag */; + return node.kind === 300 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298 /* JSDocTypedefTag */; + return node.kind === 301 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299 /* JSDocPropertyTag */; + return node.kind === 302 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; + return node.kind === 302 /* JSDocPropertyTag */ || node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287 /* JSDocTypeLiteral */; + return node.kind === 290 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288 /* JSDocSignature */; + return node.kind === 291 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -12877,7 +12924,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 300 /* SyntaxList */; + return n.kind === 303 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -12992,8 +13039,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 180 /* ObjectBindingPattern */ - || kind === 181 /* ArrayBindingPattern */; + || kind === 182 /* ObjectBindingPattern */ + || kind === 183 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13008,13 +13055,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; default: return false; @@ -13025,11 +13072,11 @@ var ts; switch (kind) { case 153 /* MethodSignature */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: case 164 /* ConstructorType */: return true; default: @@ -13051,11 +13098,11 @@ var ts; || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ || kind === 160 /* IndexSignature */ - || kind === 212 /* SemicolonClassElement */; + || kind === 215 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); + return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -13090,9 +13137,9 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 /* PropertyAssignment */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 272 /* SpreadAssignment */ + return kind === 273 /* PropertyAssignment */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 275 /* SpreadAssignment */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */; @@ -13100,7 +13147,7 @@ var ts; ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ @@ -13113,14 +13160,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 207 /* ExpressionWithTypeArguments */ - || kind === 279 /* JSDocAllType */ - || kind === 280 /* JSDocUnknownType */ - || kind === 281 /* JSDocNullableType */ - || kind === 282 /* JSDocNonNullableType */ - || kind === 283 /* JSDocOptionalType */ - || kind === 284 /* JSDocFunctionType */ - || kind === 285 /* JSDocVariadicType */; + || kind === 209 /* ExpressionWithTypeArguments */ + || kind === 282 /* JSDocAllType */ + || kind === 283 /* JSDocUnknownType */ + || kind === 284 /* JSDocNullableType */ + || kind === 285 /* JSDocNonNullableType */ + || kind === 286 /* JSDocOptionalType */ + || kind === 287 /* JSDocFunctionType */ + || kind === 288 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13145,8 +13192,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 /* ArrayBindingPattern */ - || kind === 180 /* ObjectBindingPattern */; + return kind === 183 /* ArrayBindingPattern */ + || kind === 182 /* ObjectBindingPattern */; } return false; } @@ -13154,15 +13201,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 /* ArrayLiteralExpression */ - || kind === 184 /* ObjectLiteralExpression */; + return kind === 185 /* ArrayLiteralExpression */ + || kind === 186 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 /* BindingElement */ - || kind === 206 /* OmittedExpression */; + return kind === 184 /* BindingElement */ + || kind === 208 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13171,9 +13218,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return true; } return false; @@ -13194,8 +13241,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return true; } return false; @@ -13207,8 +13254,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return true; } return false; @@ -13217,25 +13264,25 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */ - || kind === 179 /* ImportType */; + || kind === 181 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: case 150 /* Decorator */: return true; default: @@ -13244,12 +13291,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; + return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 /* TemplateExpression */ + return kind === 204 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13260,32 +13307,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - 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 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 190 /* NewExpression */: + case 189 /* CallExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 191 /* TaggedTemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 193 /* ParenthesizedExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 209 /* NonNullExpression */: - case 210 /* MetaProperty */: + case 211 /* NonNullExpression */: + case 212 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13299,13 +13346,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 190 /* TypeAssertionExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 192 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13314,9 +13361,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -13335,15 +13382,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: - case 193 /* ArrowFunction */: - case 200 /* BinaryExpression */: - case 204 /* SpreadElement */: - case 208 /* AsExpression */: - case 206 /* OmittedExpression */: - case 303 /* CommaListExpression */: - case 302 /* PartiallyEmittedExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: + case 195 /* ArrowFunction */: + case 202 /* BinaryExpression */: + case 206 /* SpreadElement */: + case 210 /* AsExpression */: + case 208 /* OmittedExpression */: + case 306 /* CommaListExpression */: + case 305 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13351,18 +13398,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 /* TypeAssertionExpression */ - || kind === 208 /* AsExpression */; + return kind === 192 /* TypeAssertionExpression */ + || kind === 210 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 302 /* PartiallyEmittedExpression */; + return node.kind === 305 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 301 /* NotEmittedStatement */; + return node.kind === 304 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -13373,13 +13420,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return true; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13387,7 +13434,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; + return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13411,113 +13458,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */ + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */; + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 239 /* ModuleDeclaration */; + || kind === 242 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 /* NamedImports */ - || kind === 246 /* NamespaceImport */; + return kind === 250 /* NamedImports */ + || kind === 249 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; + return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 /* ArrowFunction */ - || kind === 182 /* BindingElement */ - || kind === 235 /* ClassDeclaration */ - || kind === 205 /* ClassExpression */ + return kind === 195 /* ArrowFunction */ + || kind === 184 /* BindingElement */ + || kind === 238 /* ClassDeclaration */ + || kind === 207 /* ClassExpression */ || kind === 155 /* Constructor */ - || kind === 238 /* EnumDeclaration */ - || kind === 273 /* EnumMember */ - || kind === 252 /* ExportSpecifier */ - || kind === 234 /* FunctionDeclaration */ - || kind === 192 /* FunctionExpression */ + || kind === 241 /* EnumDeclaration */ + || kind === 276 /* EnumMember */ + || kind === 255 /* ExportSpecifier */ + || kind === 237 /* FunctionDeclaration */ + || kind === 194 /* FunctionExpression */ || kind === 156 /* GetAccessor */ - || kind === 245 /* ImportClause */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 248 /* ImportSpecifier */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 262 /* JsxAttribute */ + || kind === 248 /* ImportClause */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 251 /* ImportSpecifier */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 265 /* JsxAttribute */ || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ - || kind === 239 /* ModuleDeclaration */ - || kind === 242 /* NamespaceExportDeclaration */ - || kind === 246 /* NamespaceImport */ + || kind === 242 /* ModuleDeclaration */ + || kind === 245 /* NamespaceExportDeclaration */ + || kind === 249 /* NamespaceImport */ || kind === 149 /* Parameter */ - || kind === 270 /* PropertyAssignment */ + || kind === 273 /* PropertyAssignment */ || kind === 152 /* PropertyDeclaration */ || kind === 151 /* PropertySignature */ || kind === 157 /* SetAccessor */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 237 /* TypeAliasDeclaration */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 240 /* TypeAliasDeclaration */ || kind === 148 /* TypeParameter */ - || kind === 232 /* VariableDeclaration */ - || kind === 298 /* JSDocTypedefTag */ - || kind === 292 /* JSDocCallbackTag */ - || kind === 299 /* JSDocPropertyTag */; + || kind === 235 /* VariableDeclaration */ + || kind === 301 /* JSDocTypedefTag */ + || kind === 295 /* JSDocCallbackTag */ + || kind === 302 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - 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 */; + return kind === 237 /* FunctionDeclaration */ + || kind === 256 /* MissingDeclaration */ + || kind === 238 /* ClassDeclaration */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 240 /* TypeAliasDeclaration */ + || kind === 241 /* EnumDeclaration */ + || kind === 242 /* ModuleDeclaration */ + || kind === 247 /* ImportDeclaration */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 253 /* ExportDeclaration */ + || kind === 252 /* ExportAssignment */ + || kind === 245 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - 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 === 301 /* NotEmittedStatement */ - || kind === 305 /* EndOfDeclarationMarker */ - || kind === 304 /* MergeDeclarationMarker */; + return kind === 227 /* BreakStatement */ + || kind === 226 /* ContinueStatement */ + || kind === 234 /* DebuggerStatement */ + || kind === 221 /* DoStatement */ + || kind === 219 /* ExpressionStatement */ + || kind === 218 /* EmptyStatement */ + || kind === 224 /* ForInStatement */ + || kind === 225 /* ForOfStatement */ + || kind === 223 /* ForStatement */ + || kind === 220 /* IfStatement */ + || kind === 231 /* LabeledStatement */ + || kind === 228 /* ReturnStatement */ + || kind === 230 /* SwitchStatement */ + || kind === 232 /* ThrowStatement */ + || kind === 233 /* TryStatement */ + || kind === 217 /* VariableStatement */ + || kind === 222 /* WhileStatement */ + || kind === 229 /* WithStatement */ + || kind === 304 /* NotEmittedStatement */ + || kind === 308 /* EndOfDeclarationMarker */ + || kind === 307 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 297 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -13544,10 +13591,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213 /* Block */) + if (node.kind !== 216 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { + if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { return false; } } @@ -13557,7 +13604,7 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 254 /* ExternalModuleReference */ + return kind === 257 /* ExternalModuleReference */ || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } @@ -13568,62 +13615,62 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 185 /* PropertyAccessExpression */; + || kind === 187 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 255 /* JsxElement */ - || kind === 265 /* JsxExpression */ - || kind === 256 /* JsxSelfClosingElement */ + return kind === 258 /* JsxElement */ + || kind === 268 /* JsxExpression */ + || kind === 259 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 259 /* JsxFragment */; + || kind === 262 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 /* JsxAttribute */ - || kind === 264 /* JsxSpreadAttribute */; + return kind === 265 /* JsxAttribute */ + || kind === 267 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 265 /* JsxExpression */; + || kind === 268 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 /* JsxOpeningElement */ - || kind === 256 /* JsxSelfClosingElement */; + return kind === 260 /* JsxOpeningElement */ + || kind === 259 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 /* CaseClause */ - || kind === 267 /* DefaultClause */; + return kind === 269 /* CaseClause */ + || kind === 270 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 299 /* LastJSDocNode */; + return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 302 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 /* 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 >= 289 /* FirstJSDocTagNode */ && node.kind <= 299 /* LastJSDocTagNode */; + return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 302 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -13666,22 +13713,22 @@ var ts; 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 */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: + case 179 /* MappedType */: + case 192 /* TypeAssertionExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 210 /* AsExpression */: + case 235 /* VariableDeclaration */: + case 237 /* FunctionDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 281 /* JSDocTypeExpression */: + case 284 /* JSDocNullableType */: + case 285 /* JSDocNonNullableType */: + case 286 /* JSDocOptionalType */: + case 287 /* JSDocFunctionType */: + case 288 /* JSDocVariadicType */: return true; } return false; @@ -13701,10 +13748,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -13716,7 +13763,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13753,7 +13800,7 @@ var ts; (function (ts) { /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; + return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -13894,6 +13941,13 @@ var ts; } /* @internal */ function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + /* @internal */ + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -13901,7 +13955,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; + } + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -14444,17 +14510,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.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; - } + function isDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; // Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. @@ -15007,7 +15071,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 274 /* SourceFile */) { + if (kind === 277 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -15071,14 +15135,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* 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 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -15103,20 +15167,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270 /* PropertyAssignment */: + case 273 /* 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 232 /* VariableDeclaration */: + case 235 /* 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 182 /* BindingElement */: + case 184 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15138,9 +15202,9 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15165,290 +15229,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172 /* InferType */: + case 174 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 179 /* ImportType */: + case 181 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: return visitNode(cbNode, node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177 /* MappedType */: + case 179 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return visitNode(cbNode, node.literal); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitNode(cbNode, node.name); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return visitNode(cbNode, node.label); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* 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 236 /* InterfaceDeclaration */: + case 239 /* 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 237 /* TypeAliasDeclaration */: + case 240 /* 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 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 278 /* JSDocTypeExpression */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 281 /* JSDocTypeExpression */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 286 /* JSDocOptionalType */: + case 288 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 282 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 281 /* JSDocNullableType */: - return visitNode(cbNode, node.type); - case 283 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 286 /* JSDocComment */: + case 289 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15457,17 +15519,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 278 /* JSDocTypeExpression */) { + node.typeExpression.kind === 281 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15475,18 +15537,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292 /* JSDocCallbackTag */: + case 295 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295 /* JSDocThisTag */: + case 298 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocSignature */: + case 291 /* 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 287 /* JSDocTypeLiteral */: + case 290 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15494,7 +15556,7 @@ var ts; } } return; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15708,7 +15770,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216 /* ExpressionStatement */); + var statement = createNode(219 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15825,13 +15887,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); // Should only be called once per node + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -15867,7 +15926,7 @@ 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(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16674,7 +16733,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 152 /* PropertyDeclaration */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return true; case 154 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -16691,8 +16750,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: return true; } } @@ -16701,42 +16760,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - 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 */: + case 237 /* FunctionDeclaration */: + case 217 /* VariableStatement */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 219 /* ExpressionStatement */: + case 232 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 230 /* SwitchStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 218 /* EmptyStatement */: + case 233 /* TryStatement */: + case 231 /* LabeledStatement */: + case 221 /* DoStatement */: + case 234 /* DebuggerStatement */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -16752,7 +16811,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232 /* VariableDeclaration */) { + if (node.kind !== 235 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16878,7 +16937,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -16940,7 +17004,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202 /* TemplateExpression */); + var template = createNode(204 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -16952,7 +17016,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211 /* TemplateSpan */); + var span = createNode(214 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -17018,10 +17082,9 @@ var ts; case 163 /* FunctionType */: case 164 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17035,14 +17098,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174 /* ThisType */); + var node = createNode(176 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279 /* JSDocAllType */); + var result = createNode(282 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, result); + return createPostfixType(286 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17050,7 +17113,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282 /* JSDocNonNullableType */); + var result = createNode(285 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17074,18 +17137,18 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(280 /* JSDocUnknownType */, pos); + var result = createNode(283 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(281 /* JSDocNullableType */, pos); + var result = createNode(284 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -17107,12 +17170,12 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, type); + return createPostfixType(286 /* JSDocOptionalType */, type); } return type; } @@ -17452,7 +17515,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177 /* MappedType */); + var node = createNode(179 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17474,13 +17537,26 @@ var ts; parseExpected(18 /* CloseBraceToken */); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24 /* DotDotDotToken */)) { + var node = createNode(170 /* RestType */, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 169 /* OptionalType */; + } + return type; + } function parseTupleType() { var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173 /* ParenthesizedType */); + var node = createNode(175 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); parseExpected(20 /* CloseParenToken */); @@ -17498,10 +17574,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178 /* LiteralType */); + var node = createNode(180 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17522,7 +17598,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(179 /* ImportType */); + var node = createNode(181 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17648,19 +17724,19 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); + type = createPostfixType(285 /* 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(281 /* JSDocNullableType */, type); + type = createPostfixType(284 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(176 /* IndexedAccessType */, type.pos); + var node = createNode(178 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); @@ -17679,21 +17755,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175 /* TypeOperator */); + var node = createNode(177 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172 /* InferType */); + var node = createNode(174 /* InferType */); parseExpected(126 /* InferKeyword */); var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); @@ -17726,10 +17802,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17813,7 +17889,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(171 /* ConditionalType */, type.pos); + var node = createNode(173 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -18006,7 +18082,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203 /* YieldExpression */); + var node = createNode(205 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -18028,11 +18104,11 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193 /* ArrowFunction */, asyncModifier.pos); + node = createNode(195 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193 /* ArrowFunction */, identifier.pos); + node = createNode(195 /* ArrowFunction */, identifier.pos); } var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; @@ -18230,7 +18306,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193 /* ArrowFunction */); + var node = createNodeWithJSDoc(195 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18294,7 +18370,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(201 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18374,39 +18450,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200 /* BinaryExpression */, left.pos); + var node = createNode(202 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208 /* AsExpression */, left.pos); + var node = createNode(210 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194 /* DeleteExpression */); + var node = createNode(196 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195 /* TypeOfExpression */); + var node = createNode(197 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196 /* VoidExpression */); + var node = createNode(198 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18422,7 +18498,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197 /* AwaitExpression */); + var node = createNode(199 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18466,7 +18542,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 192 /* 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 { @@ -18563,7 +18639,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18576,7 +18652,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18632,7 +18708,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(210 /* MetaProperty */, fullStart); + var node = createNode(212 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18707,7 +18783,7 @@ 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(185 /* PropertyAccessExpression */, expression.pos); + var node = createNode(187 /* 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); @@ -18716,8 +18792,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257 /* JsxOpeningElement */) { - var node = createNode(255 /* JsxElement */, opening.pos); + if (opening.kind === 260 /* JsxOpeningElement */) { + var node = createNode(258 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18726,15 +18802,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260 /* JsxOpeningFragment */) { - var node = createNode(259 /* JsxFragment */, opening.pos); + else if (opening.kind === 263 /* JsxOpeningFragment */) { + var node = createNode(262 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18749,7 +18825,7 @@ 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(200 /* BinaryExpression */, result.pos); + var badNode = createNode(202 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -18807,7 +18883,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263 /* JsxAttributes */); + var jsxAttributes = createNode(266 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18816,7 +18892,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18828,7 +18904,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(257 /* JsxOpeningElement */, fullStart); + node = createNode(260 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18840,7 +18916,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(256 /* JsxSelfClosingElement */, fullStart); + node = createNode(259 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18857,7 +18933,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18865,7 +18941,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265 /* JsxExpression */); + var node = createNode(268 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18887,7 +18963,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262 /* JsxAttribute */); + var node = createNode(265 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18902,7 +18978,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264 /* JsxSpreadAttribute */); + var node = createNode(267 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18910,7 +18986,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258 /* JsxClosingElement */); + var node = createNode(261 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18923,7 +18999,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261 /* JsxClosingFragment */); + var node = createNode(264 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18938,7 +19014,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190 /* TypeAssertionExpression */); + var node = createNode(192 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18949,7 +19025,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18957,14 +19033,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(211 /* 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(186 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(188 /* 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); @@ -18991,7 +19067,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -19015,7 +19091,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -19023,7 +19099,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19135,28 +19211,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204 /* SpreadElement */); + var node = createNode(206 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183 /* ArrayLiteralExpression */); + var node = createNode(185 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19168,7 +19244,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 272 /* SpreadAssignment */; + node.kind = 275 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19195,7 +19271,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 = 271 /* ShorthandPropertyAssignment */; + node.kind = 274 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -19203,14 +19279,14 @@ var ts; } } else { - node.kind = 270 /* PropertyAssignment */; + node.kind = 273 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184 /* ObjectLiteralExpression */); + var node = createNode(186 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19229,7 +19305,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(192 /* FunctionExpression */); + var node = createNodeWithJSDoc(194 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19254,7 +19330,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(210 /* MetaProperty */, fullStart); + var node_2 = createNode(212 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19271,7 +19347,7 @@ var ts; } break; } - var node = createNode(188 /* NewExpression */, fullStart); + var node = createNode(190 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19281,7 +19357,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213 /* Block */); + var node = createNode(216 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19314,12 +19390,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215 /* EmptyStatement */); + var node = createNode(218 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(217 /* IfStatement */); + var node = createNode(220 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19329,7 +19405,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218 /* DoStatement */); + var node = createNode(221 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19344,7 +19420,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219 /* WhileStatement */); + var node = createNode(222 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19368,7 +19444,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(222 /* ForOfStatement */, pos); + var forOfStatement = createNode(225 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19376,14 +19452,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(221 /* ForInStatement */, pos); + var forInStatement = createNode(224 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220 /* ForStatement */, pos); + var forStatement = createNode(223 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19401,7 +19477,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19409,7 +19485,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225 /* ReturnStatement */); + var node = createNode(228 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19418,7 +19494,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226 /* WithStatement */); + var node = createNode(229 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19427,7 +19503,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266 /* CaseClause */); + var node = createNode(269 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19435,7 +19511,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267 /* DefaultClause */); + var node = createNode(270 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19445,12 +19521,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227 /* SwitchStatement */); + var node = createNode(230 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(241 /* CaseBlock */); + var caseBlock = createNode(244 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19465,7 +19541,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(229 /* ThrowStatement */); + var node = createNode(232 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19473,7 +19549,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(230 /* TryStatement */); + var node = createNode(233 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19486,7 +19562,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269 /* CatchClause */); + var result = createNode(272 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19500,7 +19576,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231 /* DebuggerStatement */); + var node = createNode(234 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19512,12 +19588,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 228 /* LabeledStatement */; + node.kind = 231 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216 /* ExpressionStatement */; + node.kind = 219 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19684,16 +19760,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19703,9 +19779,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(223 /* ContinueStatement */); + return parseBreakOrContinueStatement(226 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(224 /* BreakStatement */); + return parseBreakOrContinueStatement(227 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19802,7 +19878,7 @@ 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(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -19825,16 +19901,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(206 /* OmittedExpression */); + return createNode(208 /* OmittedExpression */); } - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19850,14 +19926,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180 /* ObjectBindingPattern */); + var node = createNode(182 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181 /* ArrayBindingPattern */); + var node = createNode(183 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19879,7 +19955,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232 /* VariableDeclaration */); + var node = createNode(235 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19892,7 +19968,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233 /* VariableDeclarationList */); + var node = createNode(236 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19930,13 +20006,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 214 /* VariableStatement */; + node.kind = 217 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234 /* FunctionDeclaration */; + node.kind = 237 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -20118,7 +20194,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(212 /* SemicolonClassElement */); + var result = createNode(215 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -20155,10 +20231,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -20201,14 +20277,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(268 /* HeritageClause */); + var node = createNode(271 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -20225,7 +20301,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236 /* InterfaceDeclaration */; + node.kind = 239 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20234,7 +20310,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237 /* TypeAliasDeclaration */; + node.kind = 240 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20248,13 +20324,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(273 /* EnumMember */); + var node = createNodeWithJSDoc(276 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238 /* EnumDeclaration */; + node.kind = 241 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20267,7 +20343,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240 /* ModuleBlock */); + var node = createNode(243 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20278,7 +20354,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* 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 */; @@ -20290,7 +20366,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -20336,7 +20412,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 242 /* NamespaceExportDeclaration */; + node.kind = 245 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20354,7 +20430,7 @@ var ts; } } // Import statement - node.kind = 244 /* ImportDeclaration */; + node.kind = 247 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20369,7 +20445,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243 /* ImportEqualsDeclaration */; + node.kind = 246 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20383,7 +20459,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(245 /* ImportClause */, fullStart); + var importClause = createNode(248 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20393,7 +20469,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); } return finishNode(importClause); } @@ -20403,7 +20479,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(254 /* ExternalModuleReference */); + var node = createNode(257 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20426,7 +20502,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(246 /* NamespaceImport */); + var namespaceImport = createNode(249 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20441,14 +20517,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252 /* ExportSpecifier */); + return parseImportOrExportSpecifier(255 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248 /* ImportSpecifier */); + return parseImportOrExportSpecifier(251 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20473,19 +20549,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250 /* ExportDeclaration */; + node.kind = 253 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(254 /* 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. @@ -20498,7 +20574,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249 /* ExportAssignment */; + node.kind = 252 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20518,10 +20594,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ - || node.kind === 244 /* ImportDeclaration */ - || node.kind === 249 /* ExportAssignment */ - || node.kind === 250 /* ExportDeclaration */ + || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ + || node.kind === 247 /* ImportDeclaration */ + || node.kind === 252 /* ExportAssignment */ + || node.kind === 253 /* ExportDeclaration */ ? node : undefined; } @@ -20584,7 +20660,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20644,17 +20720,16 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var state = 1 /* SawAsterisk */; @@ -20740,9 +20815,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -20754,7 +20828,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286 /* JSDocComment */, start); + var result = createNode(289 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20871,6 +20945,16 @@ var ts; indent += whitespace.length; } break; + case 17 /* OpenBraceToken */: + state = 2 /* SavingComments */; + if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token @@ -20892,7 +20976,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289 /* JSDocTag */, atToken.pos); + var result = createNode(292 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20952,8 +21036,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(299 /* JSDocPropertyTag */, atToken.pos) : - createNode(293 /* JSDocParameterTag */, atToken.pos); + createNode(302 /* JSDocPropertyTag */, atToken.pos) : + createNode(296 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -20973,18 +21057,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281 /* 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 === 293 /* JSDocParameterTag */ || child.kind === 299 /* JSDocPropertyTag */) { + if (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -20995,27 +21079,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocReturnTag */, atToken.pos); + var result = createNode(297 /* 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 === 296 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296 /* JSDocTypeTag */, atToken.pos); + var result = createNode(299 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -21023,7 +21107,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -21035,7 +21119,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(185 /* PropertyAccessExpression */, node.pos); + var prop = createNode(187 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -21043,13 +21127,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291 /* JSDocClassTag */, atToken.pos); + var tag = createNode(294 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295 /* JSDocThisTag */, atToken.pos); + var tag = createNode(298 /* JSDocThisTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); @@ -21059,7 +21143,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(301 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21075,9 +21159,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 296 /* JSDocTypeTag */) { + if (child.kind === 299 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21109,7 +21193,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21123,7 +21207,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21132,7 +21216,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288 /* JSDocSignature */, start); + var jsdocSignature = createNode(291 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -21140,7 +21224,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 294 /* JSDocReturnTag */) { + if (tag && tag.kind === 297 /* JSDocReturnTag */) { return tag; } } @@ -21185,9 +21269,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 /* JSDocParameterTag */ && + if (child && (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -21261,7 +21345,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(300 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22065,6 +22149,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -23234,7 +23319,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 !== 270 /* PropertyAssignment */) { + if (element.kind !== 273 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -23311,13 +23396,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198 /* PrefixUnaryExpression */: + case 200 /* 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 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -23334,7 +23419,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25422,24 +25507,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 238 /* EnumDeclaration */: - if (ts.isConst(node)) { + case 241 /* EnumDeclaration */: + if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 240 /* ModuleBlock */: { + case 243 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -25461,7 +25546,7 @@ var ts; }); return state_1; } - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -25620,7 +25705,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 === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -25645,32 +25730,32 @@ var ts; return "__constructor" /* Constructor */; case 163 /* FunctionType */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return "__call" /* Call */; case 164 /* ConstructorType */: case 159 /* ConstructSignature */: return "__new" /* New */; case 160 /* IndexSignature */: return "__index" /* Index */; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); 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 === 284 /* 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 === 287 /* 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; @@ -25764,7 +25849,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 === 249 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 252 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -25789,7 +25874,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -25856,7 +25941,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 !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -25901,7 +25986,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -25950,8 +26035,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -25983,77 +26068,78 @@ var ts; return; } switch (node.kind) { - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: bindWhileStatement(node); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: bindDoStatement(node); break; - case 220 /* ForStatement */: + case 223 /* ForStatement */: bindForStatement(node); break; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: bindIfStatement(node); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: bindTryStatement(node); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: bindSwitchStatement(node); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: bindCaseBlock(node); break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: bindCaseClause(node); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: bindLabeledStatement(node); break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: bindCallExpressionFlow(node); break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 274 /* SourceFile */: + case 277 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213 /* Block */: - case 240 /* ModuleBlock */: + } + case 216 /* Block */: + case 243 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -26066,15 +26152,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return hasNarrowableArgument(expr); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -26083,7 +26169,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -26094,7 +26180,7 @@ var ts; } } } - if (expr.expression.kind === 185 /* PropertyAccessExpression */ && + if (expr.expression.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -26127,9 +26213,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -26207,33 +26293,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return parent.expression === node; - case 220 /* ForStatement */: - case 201 /* ConditionalExpression */: + case 223 /* ForStatement */: + case 203 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191 /* ParenthesizedExpression */) { + if (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 /* ParenthesizedExpression */ || - node.parent.kind === 198 /* PrefixUnaryExpression */ && + while (node.parent.kind === 193 /* ParenthesizedExpression */ || + node.parent.kind === 200 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -26275,7 +26361,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -26309,13 +26395,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222 /* ForOfStatement */) { + if (node.kind === 225 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233 /* VariableDeclarationList */) { + if (node.initializer.kind !== 236 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -26337,7 +26423,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225 /* ReturnStatement */) { + if (node.kind === 228 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -26357,7 +26443,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -26453,7 +26539,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* 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; @@ -26521,14 +26607,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -26539,10 +26625,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183 /* ArrayLiteralExpression */) { + else if (node.kind === 185 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204 /* SpreadElement */) { + if (e.kind === 206 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -26550,16 +26636,16 @@ var ts; } } } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270 /* PropertyAssignment */) { + if (p.kind === 273 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271 /* ShorthandPropertyAssignment */) { + else if (p.kind === 274 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272 /* SpreadAssignment */) { + else if (p.kind === 275 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -26615,7 +26701,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26626,7 +26712,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -26673,10 +26759,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 === 191 /* ParenthesizedExpression */) { + while (expr.kind === 193 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { + if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -26684,7 +26770,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26693,21 +26779,21 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 266 /* JsxAttributes */: return 1 /* IsContainer */; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 179 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -26715,32 +26801,32 @@ var ts; } // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: - case 284 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: case 163 /* FunctionType */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 269 /* CatchClause */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 241 /* CaseBlock */: + case 272 /* CatchClause */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 244 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 213 /* Block */: + case 216 /* 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 @@ -26773,20 +26859,20 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 184 /* ObjectLiteralExpression */: - case 236 /* InterfaceDeclaration */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 186 /* ObjectLiteralExpression */: + case 239 /* InterfaceDeclaration */: + case 266 /* 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 @@ -26797,21 +26883,21 @@ var ts; case 164 /* ConstructorType */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 288 /* JSDocSignature */: + case 291 /* 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 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 287 /* JSDocFunctionType */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 240 /* TypeAliasDeclaration */: + case 179 /* 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 @@ -26832,11 +26918,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { + var body = node.kind === 277 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { + if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { return true; } } @@ -26920,7 +27006,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 === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -26932,7 +27018,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 === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -26964,10 +27050,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -27108,8 +27194,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 274 /* SourceFile */ && - blockScopeContainer.kind !== 239 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 277 /* SourceFile */ && + blockScopeContainer.kind !== 242 /* 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. @@ -27205,7 +27291,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1 /* EndOfFileToken */) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -27263,11 +27353,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -27275,7 +27365,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -27303,19 +27393,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return checkStrictModeCatchClause(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkStrictModeWithStatement(node); - case 174 /* ThisType */: + case 176 /* ThisType */: seenThisKeyword = true; return; case 161 /* TypePredicate */: @@ -27324,18 +27414,18 @@ var ts; return bindTypeParameter(node); case 149 /* Parameter */: return bindParameter(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); case 158 /* CallSignature */: case 159 /* ConstructSignature */: @@ -27348,7 +27438,7 @@ var ts; // 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -27357,83 +27447,83 @@ var ts; case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 177 /* MappedType */: + case 290 /* JSDocTypeLiteral */: + case 179 /* MappedType */: return bindAnonymousTypeWorker(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return bindFunctionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return bindJsxAttributes(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return bindImportClause(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return bindExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return bindExportAssignment(node); - case 274 /* SourceFile */: + case 277 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213 /* Block */: + case 216 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 293 /* JSDocParameterTag */: - if (node.parent.kind === 288 /* JSDocSignature */) { + case 296 /* JSDocParameterTag */: + if (node.parent.kind === 291 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { break; } // falls through - case 299 /* JSDocPropertyTag */: + case 302 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -27465,7 +27555,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 /* 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 @@ -27479,7 +27569,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274 /* SourceFile */) { + if (node.parent.kind !== 277 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -27564,8 +27654,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 */) { @@ -27592,7 +27682,7 @@ var ts; 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 274 /* SourceFile */: + case 277 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -27604,7 +27694,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -27661,9 +27751,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + : propertyAccess.parent.parent.kind === 277 /* SourceFile */; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; @@ -27757,7 +27847,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -27790,7 +27880,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); } @@ -27820,7 +27910,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { + if (node.kind === 296 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -27897,7 +27987,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 172 /* InferType */) { + else if (node.parent.kind === 174 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -27925,13 +28015,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || // report error on class declarations - node.kind === 235 /* ClassDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -27988,43 +28078,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); @@ -28035,11 +28125,11 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -28091,12 +28181,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* 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 === 183 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -28145,8 +28235,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 === 208 /* AsExpression */ - || expressionKind === 190 /* TypeAssertionExpression */) { + if (expressionKind === 210 /* AsExpression */ + || expressionKind === 192 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -28523,13 +28613,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -28540,25 +28630,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 209 /* NonNullExpression */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 211 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: case 10 /* JsxText */: - case 258 /* JsxClosingElement */: - case 259 /* JsxFragment */: - case 260 /* JsxOpeningFragment */: - case 261 /* JsxClosingFragment */: - case 262 /* JsxAttribute */: - case 263 /* JsxAttributes */: - case 264 /* JsxSpreadAttribute */: - case 265 /* JsxExpression */: + case 261 /* JsxClosingElement */: + case 262 /* JsxFragment */: + case 263 /* JsxOpeningFragment */: + case 264 /* JsxClosingFragment */: + case 265 /* JsxAttribute */: + case 266 /* JsxAttributes */: + case 267 /* JsxSpreadAttribute */: + case 268 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -28566,11 +28656,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: - case 271 /* ShorthandPropertyAssignment */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 274 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -28584,14 +28674,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 222 /* ForOfStatement */: + case 225 /* 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 203 /* YieldExpression */: + case 205 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -28618,19 +28708,21 @@ var ts; 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 */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 174 /* InferType */: + case 175 /* ParenthesizedType */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: + case 245 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; @@ -28652,10 +28744,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -28667,18 +28759,18 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; @@ -28688,7 +28780,7 @@ var ts; // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -28706,8 +28798,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 183 /* ArrayLiteralExpression */: - case 188 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: + case 190 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -28715,26 +28807,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -28750,27 +28842,27 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 183 /* ArrayLiteralExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return 942011713 /* ClassExcludes */; case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; @@ -28792,24 +28884,24 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 269 /* CatchClause */: + case 272 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: - case 191 /* ParenthesizedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: + case 193 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -29098,6 +29190,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -29171,7 +29264,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -29269,6 +29361,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -29327,7 +29420,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -29384,6 +29477,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; /** @@ -29597,143 +29691,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - 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) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - 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)); // 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)); // TODO: GH#18217 - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896 /* TypeParameters */, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - 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)] : []; // 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)); })); // TODO: GH#18217 - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - 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)); // TODO: GH#18217 - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -29771,6 +29728,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -29896,22 +29878,57 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { - var message_2 = target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */ + var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); + var isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 /* LessThan */ ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -29986,7 +30003,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -30044,17 +30061,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 182 /* BindingElement */) { + if (declaration.kind === 184 /* 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, 182 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 184 /* 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, 232 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235 /* VariableDeclaration */), usage); } - else if (declaration.kind === 232 /* VariableDeclaration */) { + else if (declaration.kind === 235 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -30072,12 +30089,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 === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* 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 === 249 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 252 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -30085,9 +30102,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214 /* VariableStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 217 /* VariableStatement */: + case 223 /* ForStatement */: + case 225 /* 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)) { @@ -30159,7 +30176,7 @@ 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 !== 286 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -30179,7 +30196,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171 /* ConditionalType */) { + else if (location.kind === 173 /* 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; @@ -30193,14 +30210,14 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 277 /* 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 */)) { @@ -30224,7 +30241,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { break; } } @@ -30238,7 +30255,7 @@ var ts; } } break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -30261,9 +30278,9 @@ var ts; } } break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -30279,7 +30296,7 @@ var ts; } break loop; } - if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -30287,7 +30304,7 @@ var ts; } } break; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* 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; @@ -30309,7 +30326,7 @@ var ts; // case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* 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); @@ -30322,14 +30339,14 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -30364,8 +30381,8 @@ var ts; location = location.parent; } break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -30384,7 +30401,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -30458,7 +30475,7 @@ 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 === 242 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 245 /* 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 } } @@ -30467,12 +30484,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 239 /* ModuleDeclaration */: // For `namespace N { N; }` + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -30540,9 +30557,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -30606,18 +30623,26 @@ 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 === 238 /* EnumDeclaration */) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32 /* Class */) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256 /* RegularEnum */) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -30630,13 +30655,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 245 /* ImportClause */: + case 248 /* ImportClause */: return node.parent; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return node.parent.parent; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -30646,7 +30671,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -30834,20 +30859,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 249 /* ExportAssignment */: - case 200 /* BinaryExpression */: + case 252 /* ExportAssignment */: + case 202 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -30908,11 +30933,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 252 /* ExportSpecifier */) { + else if (node.kind === 255 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -30940,7 +30965,7 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -30964,7 +30989,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -31129,10 +31154,19 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages( - /*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)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages( + /*details*/ undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : 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)) + : undefined; 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)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -31158,7 +31192,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -31391,6 +31425,12 @@ var ts; var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -31409,25 +31449,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -31443,12 +31477,12 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -31545,7 +31579,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, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -31657,10 +31691,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -31713,8 +31747,8 @@ var ts; // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || - entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || + entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -31796,64 +31830,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; // TODO: GH#18217 + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -31861,6 +31864,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -31978,7 +31983,7 @@ var ts; 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 & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -32047,7 +32052,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 === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -32085,7 +32090,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; + return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -32133,8 +32138,15 @@ var ts; } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -32348,7 +32360,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 === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -32402,7 +32414,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -32410,7 +32422,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); 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 isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -32419,7 +32431,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; + var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -32429,7 +32442,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 === 182 /* BindingElement */) { + if (clone.kind === 184 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -32513,17 +32526,49 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + 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, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= 16777216 /* InInitialEntityName */; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216 /* InInitialEntityName */; var isTypeOf = meaning === 67216319 /* Value */; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -32697,8 +32742,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 !== 173 /* ParenthesizedType */; }); - if (node.kind === 237 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); + if (node.kind === 240 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -32706,11 +32751,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 /* ModuleBlock */ && + node.parent.kind === 243 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -32730,42 +32775,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 - var file = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); - if (!file || !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); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205 /* ClassExpression */: - return "(Anonymous class)"; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - return "(Anonymous function)"; + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + context.encounteredError = true; + } + return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -32790,27 +32815,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* 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 182 /* BindingElement */: + case 184 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 232 /* VariableDeclaration */: + case 235 /* 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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 234 /* FunctionDeclaration */: - case 238 /* EnumDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 241 /* EnumDeclaration */: + case 246 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -32818,7 +32843,7 @@ 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 !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -32840,31 +32865,31 @@ var ts; case 158 /* CallSignature */: case 160 /* IndexSignature */: case 149 /* Parameter */: - case 240 /* ModuleBlock */: + case 243 /* 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 */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 175 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: return false; // Type parameters are always visible case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 274 /* SourceFile */: - case 242 /* NamespaceExportDeclaration */: + case 277 /* SourceFile */: + case 245 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return false; default: return false; @@ -32873,10 +32898,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 252 /* ExportSpecifier */) { + else if (node.parent.kind === 255 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -32972,12 +32997,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232 /* VariableDeclaration */: - case 233 /* VariableDeclarationList */: - case 248 /* ImportSpecifier */: - case 247 /* NamedImports */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 235 /* VariableDeclaration */: + case 236 /* VariableDeclarationList */: + case 251 /* ImportSpecifier */: + case 250 /* NamedImports */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: return false; default: return true; @@ -33054,7 +33079,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180 /* ObjectBindingPattern */) { + if (pattern.kind === 182 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -33124,22 +33149,27 @@ var ts; // 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(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); + // If the parent is a tuple type, the rest element has an array type with a union of the + // remaining tuple element types. Otherwise, the rest element has an array type with same + // element type as the parent type. + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -33150,7 +33180,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2 /* Subtype */) : type; } @@ -33167,7 +33197,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -33177,11 +33207,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 === 221 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* 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, @@ -33200,7 +33230,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 /* 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 @@ -33272,20 +33302,20 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : - declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : 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 === 155 /* Constructor */ || - thisContainer.kind === 234 /* FunctionDeclaration */ || - (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 /* FunctionDeclaration */ || + (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -33306,7 +33336,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { // If we don't have an explicit JSDoc type, get the type from the expression. var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 /* Anonymous */ && @@ -33388,7 +33418,7 @@ var ts; // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -33433,12 +33463,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { 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. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -33455,7 +33486,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 /* ObjectBindingPattern */ + return pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -33524,7 +33555,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 === 249 /* ExportAssignment */) { + if (declaration.kind === 252 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -33728,8 +33759,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 202 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 187 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 202 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -33866,35 +33897,35 @@ var ts; return undefined; } switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 153 /* MethodSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 177 /* MappedType */: - case 171 /* ConditionalType */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 179 /* MappedType */: + case 173 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177 /* MappedType */) { + if (node.kind === 179 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171 /* ConditionalType */) { + else if (node.kind === 173 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && + (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -33902,7 +33933,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, 236 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -33911,9 +33942,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 235 /* ClassDeclaration */ || - node.kind === 205 /* ClassExpression */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || + node.kind === 207 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -33947,15 +33978,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - // Prefer an @augments tag because it may have type parameters. - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -33978,7 +34001,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -34011,7 +34034,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { if (type.symbol.flags & 32 /* Class */) { @@ -34074,7 +34097,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; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -34099,7 +34122,7 @@ var ts; 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 === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -34135,7 +34158,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */) { + if (declaration.kind === 239 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -34193,7 +34216,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -34220,7 +34243,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 200 /* BinaryExpression */) { + else if (expr.kind === 202 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -34234,12 +34257,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* 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 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -34253,7 +34276,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -34280,7 +34303,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 @@ -34370,7 +34393,7 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 178 /* LiteralType */: + case 180 /* LiteralType */: return true; case 167 /* ArrayType */: return isThislessType(node.elementType); @@ -34750,6 +34773,28 @@ var ts; return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 /* RestParameter */ : + i >= minLength_1 ? 4096 /* OptionalParameter */ : 0; + var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); @@ -34927,6 +34972,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); @@ -34935,6 +34981,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); @@ -35093,7 +35140,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 175 /* TypeOperator */ && + return constraintDeclaration.kind === 177 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -35213,6 +35260,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144 /* Union */)) { @@ -35670,10 +35728,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 === 283 /* JSDocOptionalType */ + node.type && node.type.kind === 286 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -35692,7 +35750,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -35707,7 +35765,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -35802,7 +35860,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178 /* LiteralType */) { + if (type && type.kind === 180 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -35850,9 +35908,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 8192 /* RestParameter */); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { // Replace the last parameter with a rest parameter. parameters.pop(); @@ -35958,9 +36015,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -36003,16 +36060,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1 /* Number */) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -36114,32 +36168,40 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - // When an 'infer T' declaration is immediately contained in a type reference node - // (such as 'Foo'), T's constraint is inferred from the constraint of the - // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are - // present, we form an intersection of the inferred constraint types. - if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - // Type parameter constraints can reference other type parameters so - // constraints need to be instantiated. If instantiation produces the - // type parameter itself, we discard that inference. For example, in - // type Foo = [T, U]; - // type Bar = T extends Foo ? Foo : T; - // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174 /* InferType */) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162 /* TypeReference */) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + // When an 'infer T' declaration is immediately contained in a rest parameter + // declaration, we infer an 'unknown[]' constraint. + else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -36234,7 +36296,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 !== 290 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 293 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -36293,7 +36355,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -36386,9 +36448,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -36500,9 +36562,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return declaration; } } @@ -36623,18 +36685,26 @@ var ts; // // Note that the generic type created by this function has no symbol associated with it. The same // is true for each of the synthesized type parameters. - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536 /* TypeParameter */); - typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + if (i < maxLength) { + var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4 /* Property */, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; @@ -36652,21 +36722,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -37060,7 +37156,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -37125,7 +37221,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -37145,6 +37241,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { @@ -37155,7 +37257,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* 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))) { @@ -37172,14 +37274,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* 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)); } @@ -37285,7 +37395,7 @@ 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 === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -37425,7 +37535,7 @@ var ts; return true; } while (node) { - if (node.kind === 171 /* ConditionalType */) { + if (node.kind === 173 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -37523,7 +37633,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } 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); + var errorMessage = 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_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -37729,7 +37842,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -37748,8 +37861,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return anyType; case 142 /* UnknownKeyword */: return unknownType; @@ -37771,16 +37884,16 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 162 /* TypeReference */: return getTypeFromTypeReference(node); case 161 /* TypePredicate */: return booleanType; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); @@ -37788,38 +37901,41 @@ var ts; return getTypeFromArrayTypeNode(node); case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return getTypeFromOptionalTypeNode(node); + case 171 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 173 /* ParenthesizedType */: - case 282 /* JSDocNonNullableType */: - case 278 /* JSDocTypeExpression */: + case 175 /* ParenthesizedType */: + case 170 /* RestType */: + case 285 /* JSDocNonNullableType */: + case 281 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 172 /* InferType */: + case 174 /* InferType */: return getTypeFromInferTypeNode(node); - case 179 /* ImportType */: + case 181 /* 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 @@ -37968,7 +38084,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | (ts.getCheckFlags(symbol) & 1024 /* Late */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (1024 /* Late */ | 4096 /* OptionalParameter */ | 8192 /* RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -37979,11 +38095,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -38048,14 +38159,14 @@ 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 === 213 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -38193,32 +38304,32 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive); - case 262 /* JsxAttribute */: { + case 265 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265 /* JsxExpression */: { + case 268 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -38235,7 +38346,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* 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); @@ -38245,7 +38356,7 @@ var ts; } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 213 /* Block */ ? false : isContextSensitive(body); + return body.kind === 216 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -38315,8 +38426,206 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268 /* JsxExpression */: + case 193 /* ParenthesizedExpression */: + return elaborateError(node.expression, source, target); + case 202 /* BinaryExpression */: + switch (node.operatorToken.kind) { + case 58 /* EqualsToken */: + case 26 /* CommaToken */: + return elaborateError(node.right, source, target); + } + break; + case 186 /* ObjectLiteralExpression */: + return elaborateObjectLiteral(node, source, target); + case 185 /* ArrayLiteralExpression */: + return elaborateArrayLiteral(node, source, target); + case 266 /* JsxAttributes */: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator, source, target) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + var resultObj = {}; + // Use the expression type, if available + var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + getIndexInfoOfType(target, 0 /* String */) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3 /*break*/, 3]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2 /*return*/]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3 /*break*/, 4]; + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3 /*break*/, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3 /*break*/, 3]; + nameType = getLiteralType(i); + return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3 /*break*/, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 32768 /* Never */)) { + return [3 /*break*/, 7]; + } + _b = prop.kind; + switch (_b) { + case 157 /* SetAccessor */: return [3 /*break*/, 2]; + case 156 /* GetAccessor */: return [3 /*break*/, 2]; + case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + } + return [3 /*break*/, 6]; + case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3 /*break*/, 7]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3 /*break*/, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** * This is *not* a bi-directional relationship. @@ -38337,13 +38646,20 @@ var ts; if (source === target) { return -1 /* True */; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0 /* False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0 /* False */; + } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; @@ -38364,14 +38680,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -38390,7 +38703,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0 /* False */; } @@ -38465,30 +38778,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - // If both have rest parameters, get the max and add 1 to - // compensate for the rest parameter. - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - // Return the count for whichever signature doesn't have rest parameters. - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -38509,11 +38798,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { + return relation === 1 /* Succeeded */; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, false); + enumRelation.set(id, 3 /* FailedAndReported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -38524,13 +38813,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); + enumRelation.set(id, 3 /* FailedAndReported */); + } + else { + enumRelation.set(id, 2 /* Failed */); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1 /* Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -38621,7 +38913,7 @@ var ts; * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -38651,12 +38943,16 @@ var ts; var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); // Cause the error to appear with the error that triggered it + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); // Cause the error to appear with the error that triggered it } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); // TODO: GH#18217 + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { @@ -38738,6 +39034,22 @@ var ts; if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); + if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + target = nullStrippedTarget; + } + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; @@ -38989,11 +39301,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } return 0 /* False */; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072 /* Object */) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4 /* Reference */) { + return source.target === target.target; + } + if (overlapObjFlags & 16 /* Anonymous */) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { var match; @@ -39125,9 +39455,8 @@ var ts; var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { - // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported - // failure and continue computing the relation such that errors get reported. - relation.set(id, 3 /* FailedAndReported */); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -39414,7 +39743,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -39437,6 +39766,33 @@ var ts; } } var result = -1 /* True */; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0 /* False */; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0 /* False */; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0 /* False */; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -39958,20 +40314,26 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); // A source signature matches a target signature if the two signatures have the same number of required, // optional, and rest parameters. - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } // A source signature partially matches a target signature if the target signature has no fewer required // parameters and no more overall parameters than the source signature (where a signature with a rest // parameter is always considered to have more overall parameters than one without). - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -40013,10 +40375,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0 /* False */; @@ -40036,9 +40398,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -40088,7 +40447,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); @@ -40135,6 +40499,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -40194,7 +40564,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -40407,7 +40777,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -40417,23 +40787,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* 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 177 /* MappedType */: + case 179 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -40450,24 +40820,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -40606,10 +40974,14 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - // Two tuple types with different arity are definitely unrelated. + // Two tuple types with incompatible arities are definitely unrelated. // Two object types that each have a property that is unmatched in the other are definitely unrelated. - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) && !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false); } function getTypeFromInference(inference) { @@ -40892,12 +41264,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -41012,17 +41405,14 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + // If we have contravariant inferences we find the best common subtype and treat + // that as a single covariant candidate. + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { 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 & 32768 /* Never */ && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - // We only have contravariant inferences, infer the best common subtype of those - inferredType = getContravariantInference(inference); } else if (context.flags & 2 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -41099,13 +41489,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 185 /* PropertyAccessExpression */) { + if (node.kind === 187 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182 /* BindingElement */) { + if (node.kind === 184 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -41114,7 +41504,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180 /* ObjectBindingPattern */) { + if (parent.kind === 182 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: @@ -41137,26 +41527,26 @@ var ts; switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && + (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 185 /* PropertyAccessExpression */: - return target.kind === 185 /* PropertyAccessExpression */ && + case 187 /* PropertyAccessExpression */: + return target.kind === 187 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182 /* BindingElement */: - if (target.kind !== 185 /* PropertyAccessExpression */) + case 184 /* BindingElement */: + if (target.kind !== 187 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232 /* VariableDeclaration */) { + if (source.parent.parent.kind === 235 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -41164,7 +41554,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185 /* PropertyAccessExpression */) { + while (source.kind === 187 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -41177,7 +41567,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 === 185 /* PropertyAccessExpression */ && + return target.kind === 187 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -41185,7 +41575,7 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185 /* PropertyAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -41229,7 +41619,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -41355,7 +41745,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; } @@ -41363,15 +41753,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -41388,21 +41778,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return stringType; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return undefinedType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -41410,7 +41800,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 /* ObjectBindingPattern */ ? + var type = pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -41428,35 +41818,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221 /* ForInStatement */) { + if (node.parent.parent.kind === 224 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.parent.kind === 225 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 /* VariableDeclaration */ ? + return node.kind === 235 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? + return node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 /* VariableDeclaration */ && node.initializer && + return node.kind === 235 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && + node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -41468,13 +41858,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - 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 ? + return parent.kind === 193 /* ParenthesizedExpression */ || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -41637,11 +42027,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - 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 */ && + var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 200 /* BinaryExpression */ && + parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -41689,7 +42079,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 === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -41760,7 +42150,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 !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 187 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -41816,7 +42206,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 /* CallExpression */ ? + var expr = node.kind === 189 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -41824,7 +42214,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -41989,7 +42379,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 /* PropertyAccessExpression */ && + return expr.kind === 187 /* PropertyAccessExpression */ && computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -42040,10 +42430,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 === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -42258,7 +42648,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -42278,15 +42668,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -42322,8 +42712,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 /* ModuleBlock */ || - node.kind === 274 /* SourceFile */ || + node.kind === 243 /* ModuleBlock */ || + node.kind === 277 /* SourceFile */ || node.kind === 152 /* PropertyDeclaration */; }); } @@ -42369,10 +42759,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - 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; + return parent.kind === 187 /* PropertyAccessExpression */ || + parent.kind === 189 /* CallExpression */ && parent.expression === node || + parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); @@ -42406,7 +42796,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 */)) { @@ -42427,7 +42817,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 === 235 /* ClassDeclaration */ + if (declaration.kind === 238 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -42439,12 +42829,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205 /* ClassExpression */) { + else if (declaration.kind === 207 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 274 /* SourceFile */) { + while (container.kind !== 277 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; @@ -42494,23 +42884,23 @@ var ts; 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); + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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 === 192 /* FunctionExpression */ || - flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 /* FunctionExpression */ || + flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // 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 || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || 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 || + isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || + node.parent.kind === 211 /* NonNullExpression */ || + declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -42541,7 +42931,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -42566,8 +42956,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 === 220 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && + if (container.kind === 223 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -42581,7 +42971,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 191 /* ParenthesizedExpression */) { + while (current.parent.kind === 193 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -42589,7 +42979,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -42647,7 +43037,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); // If a containing class does not have extends clause or the class extends null // skip checking whether super statement is called before "this" accessing. if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -42674,17 +43064,17 @@ var ts; 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 === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 238 /* EnumDeclaration */: + case 241 /* 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; @@ -42722,8 +43112,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 === 192 /* FunctionExpression */ && - container.parent.kind === 200 /* BinaryExpression */ && + if (container.kind === 194 /* FunctionExpression */ && + container.parent.kind === 202 /* 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 @@ -42754,7 +43144,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -42771,12 +43161,12 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 /* 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 === 193 /* ArrowFunction */) { + while (container && container.kind === 195 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -42796,7 +43186,7 @@ var ts; 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 === 184 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -42884,7 +43274,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184 /* ObjectLiteralExpression */) { + if (container.parent.kind === 186 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -42896,7 +43286,7 @@ var ts; } // at this point the only legal case for parent is ClassLikeDeclaration var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -42928,7 +43318,7 @@ 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 === 184 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 154 /* MethodDeclaration */ || container.kind === 153 /* MethodSignature */ || @@ -42952,8 +43342,8 @@ var ts; function getContainingObjectLiteral(func) { 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 : + func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -42965,7 +43355,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193 /* ArrowFunction */) { + if (func.kind === 195 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -42992,7 +43382,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270 /* PropertyAssignment */) { + if (literal.parent.kind !== 273 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -43006,9 +43396,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 === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { + if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* 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)) { @@ -43031,27 +43421,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. @@ -43061,10 +43448,8 @@ var ts; return getTypeAtPosition(contextualSignature, indexOfParameter); } // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -43095,7 +43480,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182 /* BindingElement */) { + if (parentDeclaration.kind !== 184 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -43177,7 +43562,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189 /* TaggedTemplateExpression */) { + if (template.parent.kind === 191 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -43225,8 +43610,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504 /* StructuredType */) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, /*noReductions*/ true); } function getIndexTypeOfContextualType(type, kind) { @@ -43255,8 +43651,8 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -43322,8 +43718,8 @@ var ts; case 95 /* NullKeyword */: case 71 /* Identifier */: return true; - case 185 /* PropertyAccessExpression */: - case 191 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 193 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -43342,14 +43738,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270 /* PropertyAssignment */) + if (prop.kind !== 273 /* PropertyAssignment */) continue; 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); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine @@ -43390,52 +43786,52 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 193 /* ArrowFunction */: - case 225 /* ReturnStatement */: + case 195 /* ArrowFunction */: + case 228 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 183 /* ArrayLiteralExpression */: { + case 185 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 211 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); + case 214 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191 /* ParenthesizedExpression */: { + case 193 /* 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 265 /* JsxExpression */: + case 268 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -43509,6 +43905,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -43519,8 +43916,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) @@ -43536,7 +43949,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -43581,11 +43995,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; + return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -43657,18 +44070,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 182 /* BindingElement */ && !!node.initializer) || - (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 184 /* BindingElement */ && !!node.initializer) || + (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -43693,13 +44107,17 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; + if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } @@ -43707,28 +44125,30 @@ 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 === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - 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); + else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { + if (e.kind !== 208 /* OmittedExpression */) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2 /* Subtype */); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2 /* Subtype */) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -43813,7 +44233,7 @@ var ts; var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -43827,11 +44247,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 /* PropertyAssignment */ || - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 273 /* PropertyAssignment */ || + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -43852,8 +44272,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 === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -43878,7 +44298,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272 /* SpreadAssignment */) { + else if (memberDecl.kind === 275 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -43972,13 +44392,16 @@ var ts; type.flags & 131072 /* Object */ && !isGenericMappedType(type) || type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { + function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -43986,6 +44409,9 @@ var ts; else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -44008,16 +44434,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - // TODO (yuisu): comment - switch (tagName.kind) { - case 185 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: - return false; - case 71 /* Identifier */: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -44060,7 +44477,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -44083,7 +44500,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 255 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 /* 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); @@ -44244,12 +44661,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -44286,6 +44715,10 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928 /* Type */); + } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -44692,7 +45125,7 @@ var ts; // sourceAttributesType is a type of an attributes properties. // i.e
// attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. @@ -44713,31 +45146,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -44784,9 +45193,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? + var errorNode = node.kind === 187 /* PropertyAccessExpression */ || node.kind === 235 /* VariableDeclaration */ ? node.name : - node.kind === 179 /* ImportType */ ? + node.kind === 181 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -44956,7 +45365,7 @@ 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 !== 185 /* PropertyAccessExpression */ || + if (node.kind !== 187 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; @@ -44988,16 +45397,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + else if (valueDeclaration.kind === 238 /* 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)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -45005,7 +45419,7 @@ var ts; switch (node.kind) { case 152 /* PropertyDeclaration */: return true; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -45061,13 +45475,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319 /* Value */); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319 /* Value */); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -45126,16 +45546,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179 /* ImportType */: + case 181 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -45169,7 +45589,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer.kind === 236 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -45198,7 +45618,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 /* ForInStatement */ && + if (node.kind === 224 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -45216,7 +45636,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 190 /* 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); @@ -45283,7 +45703,7 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (node.kind !== 150 /* Decorator */) { @@ -45349,14 +45769,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204 /* SpreadElement */) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -45368,12 +45785,12 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* 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 = node.typeArguments; - if (node.template.kind === 202 /* TemplateExpression */) { + if (node.template.kind === 204 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -45395,8 +45812,8 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 188 /* NewExpression */); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190 /* NewExpression */); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. @@ -45409,15 +45826,14 @@ var ts; } // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -45442,9 +45858,10 @@ var ts; // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1 /* InferUnionTypes */, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8 /* ReturnType */); @@ -45494,7 +45911,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -45509,11 +45926,13 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; 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 !== 206 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -45527,6 +45946,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) @@ -45544,6 +45967,35 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + // We are inferring from a spread expression in the last argument position, i.e. both the parameter + // and the argument are ...x forms. + return arg.kind === 213 /* SyntheticExpression */ ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -45603,7 +46055,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 190 /* 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. @@ -45617,24 +46069,32 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; 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 !== 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. - // In that case, we should check the argument. - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { + if (i === restIndex && (restType.flags & 65536 /* TypeParameter */ || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, /*context*/ undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + // 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. + // In that case, we should check the argument. + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } @@ -45644,9 +46104,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { + if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { return callee.expression; } } @@ -45661,10 +46121,10 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [undefined]; // TODO: GH#18217 - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -45681,7 +46141,28 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + // We have a spread argument in the last position and no other spread arguments. If the type + // of the argument is a tuple type, spread the tuple elements into the argument list. We can + // call checkExpressionCached because spread expressions never have a contextual type. + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213 /* SyntheticExpression */, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } /** @@ -45700,8 +46181,8 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; case 152 /* PropertyDeclaration */: @@ -45746,7 +46227,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* 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); @@ -45791,7 +46272,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -45846,7 +46327,7 @@ 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 === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -45895,7 +46376,7 @@ var ts; if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -45908,7 +46389,7 @@ 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 === 150 /* Decorator */ || - (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { + (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -45921,7 +46402,7 @@ var ts; // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -45941,7 +46422,7 @@ 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 === 189 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -46016,7 +46497,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 === 187 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 /* 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 @@ -46063,10 +46544,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -46181,11 +46662,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -46201,7 +46683,7 @@ var ts; 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)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -46380,8 +46862,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -46407,8 +46888,8 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -46484,16 +46965,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -46569,7 +47050,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -46583,7 +47065,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185 /* PropertyAccessExpression */) { + while (parent && parent.kind === 187 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -46615,7 +47097,7 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 188 /* NewExpression */) { + if (node.kind === 190 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 /* Constructor */ && @@ -46689,7 +47171,7 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -46746,9 +47228,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 234 /* FunctionDeclaration */ + ? 237 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 232 /* VariableDeclaration */ + ? 235 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -46826,10 +47308,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1 /* Number */) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536 /* TypeParameter */) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -46868,11 +47447,11 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -46937,7 +47516,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213 /* Block */) { + if (func.body.kind !== 216 /* 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 @@ -47026,7 +47605,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -47051,7 +47630,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -47094,11 +47673,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; case 154 /* MethodDeclaration */: - return func.parent.kind === 184 /* ObjectLiteralExpression */; + return func.parent.kind === 186 /* ObjectLiteralExpression */; default: return false; } @@ -47122,7 +47701,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -47162,7 +47741,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -47223,7 +47802,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213 /* Block */) { + if (node.body.kind === 216 /* Block */) { checkSourceElement(node.body); } else { @@ -47236,10 +47815,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -47269,7 +47848,7 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && + (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* 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); @@ -47286,13 +47865,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* 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 === 246 /* NamespaceImport */; + return !!declaration && declaration.kind === 249 /* NamespaceImport */; } } } @@ -47301,7 +47880,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 !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -47310,7 +47889,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { + if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -47487,7 +48066,7 @@ 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 === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { var name = property.name; if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); @@ -47502,7 +48081,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 274 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -47514,7 +48093,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 === 272 /* SpreadAssignment */) { + else if (property.kind === 275 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -47549,27 +48128,23 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206 /* OmittedExpression */) { - if (element.kind !== 204 /* SpreadElement */) { + if (element.kind !== 208 /* OmittedExpression */) { + if (element.kind !== 206 /* SpreadElement */) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - // We still need to check element expression here because we may need to set appropriate flag on the expression - // such as NodeCheckFlags.LexicalThis on "this"expression. - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -47578,12 +48153,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -47592,7 +48170,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -47608,25 +48186,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184 /* ObjectLiteralExpression */) { + if (target.kind === 186 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183 /* ArrayLiteralExpression */) { + if (target.kind === 185 /* 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 === 272 /* SpreadAssignment */ ? + var error = target.parent.kind === 275 /* 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)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -47644,35 +48222,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 189 /* TaggedTemplateExpression */: - case 202 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - 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 */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 197 /* TypeOfExpression */: + case 211 /* NonNullExpression */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: return true; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -47684,9 +48262,9 @@ var ts; } return false; // Some forms listed here for clarity - 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 + case 198 /* VoidExpression */: // Explicit opt-out + case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -47702,7 +48280,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -47901,7 +48479,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -47922,7 +48500,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34 /* EqualsEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -47979,7 +48573,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' return anyType; @@ -48004,7 +48598,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263 /* JsxAttributes */) { + if (node.kind === 266 /* 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; @@ -48040,7 +48634,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; + return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -48142,7 +48736,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 === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 /* 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) { @@ -48192,8 +48786,8 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 188 /* 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) { @@ -48229,74 +48823,76 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checkCallExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return checkClassExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return checkAssertion(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return checkNonNullAssertion(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return checkMetaProperty(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkDeleteExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return checkVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return checkAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return undefinedWideningType; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return checkYieldExpression(node); - case 265 /* JsxExpression */: + case 213 /* SyntheticExpression */: + return node.type; + case 268 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return checkJsxElement(node, checkMode); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -48325,6 +48921,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 /* Instantiable */ && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -48351,7 +48950,7 @@ var ts; } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -48412,10 +49011,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 158 /* CallSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 163 /* FunctionType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -48436,7 +49035,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 === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { + else if (name.kind === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -48449,7 +49048,7 @@ var ts; checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + else if (node.kind === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -48514,7 +49113,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -48643,7 +49242,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* 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 @@ -48731,7 +49330,7 @@ var ts; // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -48753,7 +49352,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 === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -48904,11 +49503,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170 /* RestType */) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169 /* OptionalType */) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -48922,7 +49538,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 186 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 /* 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)); } @@ -48959,7 +49575,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* 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); @@ -48975,9 +49591,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 !== 236 /* InterfaceDeclaration */ && - n.parent.kind !== 235 /* ClassDeclaration */ && - n.parent.kind !== 205 /* ClassExpression */ && + if (n.parent.kind !== 239 /* InterfaceDeclaration */ && + n.parent.kind !== 238 /* ClassDeclaration */ && + n.parent.kind !== 207 /* 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 @@ -49107,7 +49723,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 /* 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 @@ -49118,7 +49734,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 === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -49247,22 +49863,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 249 /* ExportAssignment */: + case 252 /* 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 */; @@ -49270,17 +49886,17 @@ 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 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 248 /* 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 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 234 /* FunctionDeclaration */: - case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 237 /* FunctionDeclaration */: + case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -49551,7 +50167,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -49614,12 +50230,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -49651,7 +50267,7 @@ var ts; } } return commonEntityName; - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); case 162 /* TypeReference */: return node.typeName; @@ -49684,7 +50300,7 @@ var ts; 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -49773,7 +50389,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -49785,7 +50401,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -49868,27 +50484,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274 /* SourceFile */: - case 239 /* ModuleDeclaration */: - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 242 /* ModuleDeclaration */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -49902,7 +50518,7 @@ var ts; case 159 /* ConstructSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -49915,10 +50531,7 @@ var ts; 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.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -49948,7 +50561,7 @@ var ts; } break; case 160 /* IndexSignature */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: // Can't be private break; default: @@ -49964,7 +50577,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -49999,7 +50612,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -50017,9 +50630,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -50034,7 +50647,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0 /* Local */, unuseds.length === 1 @@ -50052,7 +50665,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -50073,7 +50686,7 @@ var ts; 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)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -50087,22 +50700,22 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; + return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 213 /* Block */) { + if (node.kind === 216 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -50197,7 +50810,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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 /* 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)); } @@ -50212,7 +50825,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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 277 /* 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)); } @@ -50247,7 +50860,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 === 232 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -50259,17 +50872,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 214 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 217 /* 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 === 213 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 240 /* ModuleBlock */ || - container.kind === 239 /* ModuleDeclaration */ || - container.kind === 274 /* SourceFile */); + (container.kind === 216 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 243 /* ModuleBlock */ || + container.kind === 242 /* ModuleDeclaration */ || + container.kind === 277 /* 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 @@ -50295,7 +50908,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 185 /* PropertyAccessExpression */) { + if (n.kind === 187 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -50315,7 +50928,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 182 /* BindingElement */) { + symbol.valueDeclaration.kind === 184 /* 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) { @@ -50368,8 +50981,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182 /* BindingElement */) { - if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 184 /* BindingElement */) { + if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -50390,7 +51003,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -50403,13 +51016,13 @@ var ts; // 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 !== 221 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -50426,8 +51039,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221 /* ForInStatement */) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -50442,7 +51055,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -50452,7 +51065,7 @@ var ts; 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 === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -50467,8 +51080,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || - (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || + (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -50507,7 +51120,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215 /* EmptyStatement */) { + if (node.thenStatement.kind === 218 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -50527,12 +51140,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -50566,14 +51179,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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. @@ -50587,7 +51200,7 @@ var ts; // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -50605,7 +51218,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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); @@ -50619,7 +51232,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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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)) { @@ -50983,7 +51596,7 @@ var ts; } } else if (func.kind === 155 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -50999,7 +51612,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -51032,7 +51645,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 === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -51044,7 +51657,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 269 /* 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. @@ -51073,7 +51686,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -51171,16 +51784,17 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } // perform property check if property or indexer is declared in 'type' // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || + if (propDeclaration && name && + (propDeclaration.kind === 202 /* BinaryExpression */ || + name.kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -51354,7 +51968,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); @@ -51366,6 +51980,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -51432,7 +52050,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -51451,7 +52069,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -51477,7 +52095,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; + return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -51516,7 +52134,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 === 205 /* ClassExpression */) { + if (derivedClassDecl.kind === 207 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -51630,7 +52248,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -51693,7 +52311,7 @@ var ts; } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -51708,7 +52326,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -51735,7 +52353,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -51745,7 +52363,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -51773,7 +52391,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: var identifier = expr; @@ -51781,14 +52399,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* 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 === 185 /* PropertyAccessExpression */) { + if (ex.kind === 187 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -51820,8 +52438,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -51835,7 +52453,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304 /* Ambient */) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -51851,7 +52469,7 @@ var ts; if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -51859,7 +52477,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 !== 238 /* EnumDeclaration */) { + if (declaration.kind !== 241 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -51882,8 +52500,8 @@ var ts; var declarations = symbol.declarations; 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))) && + if ((declaration.kind === 238 /* ClassDeclaration */ || + (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -51946,7 +52564,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, 235 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -51996,23 +52614,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* 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 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -52023,12 +52641,12 @@ var ts; break; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 234 /* FunctionDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -52056,7 +52674,7 @@ var ts; node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -52073,9 +52691,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - 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 */ ? + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -52108,14 +52726,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 === 252 /* ExportSpecifier */ ? + var message = node.kind === 255 /* 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 === 252 /* ExportSpecifier */ + && node.kind === 255 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -52142,7 +52760,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -52166,7 +52784,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -52202,10 +52820,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -52222,7 +52840,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -52251,8 +52869,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 === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -52340,7 +52958,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -52358,10 +52976,10 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -52399,111 +53017,113 @@ var ts; return checkArrayType(node); case 168 /* TupleType */: return checkTupleType(node); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: + case 169 /* OptionalType */: + case 170 /* RestType */: return checkSourceElement(node.type); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return checkTypeOperator(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return checkConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return checkInferType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return checkImportType(node); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 282 /* JSDocNonNullableType */: - case 281 /* JSDocNullableType */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: - case 287 /* JSDocTypeLiteral */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: + case 290 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 278 /* JSDocTypeExpression */: + case 281 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return checkMappedType(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return checkBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return checkVariableStatement(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return checkExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return checkIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return checkDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return checkWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return checkForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return checkForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkForOfStatement(node); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return checkReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return checkSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return checkLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return checkThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return checkTryStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return checkBindingElement(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return checkClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return checkImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return checkExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return checkExportAssignment(node); - case 215 /* EmptyStatement */: - case 231 /* DebuggerStatement */: + case 218 /* EmptyStatement */: + case 234 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -52580,15 +53200,15 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -52597,11 +53217,17 @@ var ts; case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: checkClassExpressionDeferred(node); break; + case 259 /* JsxSelfClosingElement */: + checkJsxSelfClosingElementDeferred(node); + break; + case 258 /* JsxElement */: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -52636,7 +53262,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -52730,13 +53356,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -52744,8 +53370,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* 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. @@ -52754,7 +53380,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -52803,10 +53429,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148 /* TypeParameter */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -52820,10 +53446,10 @@ var ts; return node.parent.kind === 162 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185 /* PropertyAccessExpression */) { + while (node.parent.kind === 187 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 207 /* ExpressionWithTypeArguments */; + return node.parent.kind === 209 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -52854,10 +53480,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -52883,7 +53509,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -52893,7 +53519,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 /* PropertyAccessExpression */ && + entityName.parent.kind === 187 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -52901,7 +53527,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 /* 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); @@ -52911,7 +53537,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, 243 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -52929,7 +53555,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 === 207 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -52945,10 +53571,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293 /* JSDocParameterTag */) { + if (entityName.parent.kind === 296 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 297 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 300 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -52965,12 +53591,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185 /* PropertyAccessExpression */) { + if (entityName.kind === 187 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -52983,7 +53609,7 @@ var ts; var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 262 /* JsxAttribute */) { + else if (entityName.parent.kind === 265 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161 /* TypePredicate */) { @@ -52993,7 +53619,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -53013,8 +53639,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 /* BindingElement */ && - grandParent.kind === 180 /* ObjectBindingPattern */ && + else if (parent.kind === 184 /* BindingElement */ && + grandParent.kind === 182 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -53025,7 +53651,7 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: @@ -53040,7 +53666,7 @@ var ts; return checkExpression(node).symbol; } // falls through - case 174 /* ThisType */: + case 176 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; @@ -53058,7 +53684,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 === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* 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); @@ -53076,14 +53702,14 @@ var ts; case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -53156,28 +53782,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 222 /* ForOfStatement */) { + if (expr.parent.kind === 225 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 200 /* BinaryExpression */) { + if (expr.parent.kind === 202 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 270 /* PropertyAssignment */) { + if (expr.parent.kind === 273 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -53256,7 +53882,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -53312,7 +53938,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* 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. @@ -53367,7 +53993,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 === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -53408,16 +54034,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -53427,7 +54053,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -53508,22 +54134,23 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273 /* EnumMember */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 276 /* EnumMember */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273 /* EnumMember */) { + if (node.kind === 276 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8 /* EnumMember */)) { // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -53661,7 +54288,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } @@ -53758,7 +54385,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; + return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -53770,7 +54397,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 === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -53821,7 +54448,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -53836,12 +54463,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 /* 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, 274 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 277 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -53849,10 +54476,14 @@ var ts; var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); // Initialize global symbol table var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -53926,6 +54557,32 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -54019,7 +54676,7 @@ var ts; } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { + if (node.kind !== 241 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -54039,7 +54696,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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -54062,7 +54719,7 @@ 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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149 /* Parameter */) { @@ -54098,7 +54755,7 @@ 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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149 /* Parameter */) { @@ -54107,8 +54764,8 @@ var ts; flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -54120,13 +54777,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } 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 === 240 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -54136,14 +54793,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 238 /* 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 === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 238 /* 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 */) { @@ -54185,7 +54842,7 @@ var ts; } return false; } - else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -54220,29 +54877,29 @@ var ts; 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 242 /* ModuleDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 149 /* Parameter */: return false; default: - if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return false; } switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 236 /* InterfaceDeclaration */: - case 214 /* VariableStatement */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 217 /* VariableStatement */: + case 240 /* TypeAliasDeclaration */: return true; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -54256,9 +54913,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -54391,7 +55048,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206 /* OmittedExpression */) { + if (arg.kind === 208 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -54472,15 +55129,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 202 /* 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 === 234 /* FunctionDeclaration */ || - node.kind === 192 /* FunctionExpression */ || + ts.Debug.assert(node.kind === 237 /* FunctionDeclaration */ || + node.kind === 194 /* FunctionExpression */ || node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -54504,7 +55161,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 === 272 /* SpreadAssignment */) { + if (prop.kind === 275 /* SpreadAssignment */) { continue; } var name = prop.name; @@ -54512,7 +55169,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 /* 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); @@ -54536,8 +55193,8 @@ 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 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -54587,7 +55244,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 === 264 /* JsxSpreadAttribute */) { + if (attr.kind === 267 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -54597,7 +55254,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -54606,12 +55263,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -54626,20 +55283,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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); @@ -54708,7 +55365,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* 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); @@ -54746,7 +55403,7 @@ var ts; return true; } if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 184 /* ObjectLiteralExpression */) { + if (node.parent.kind === 186 /* 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); @@ -54775,7 +55432,7 @@ var ts; 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 === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* 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 === 166 /* TypeLiteral */) { @@ -54789,11 +55446,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228 /* LabeledStatement */: + case 231 /* 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 === 223 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 226 /* 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); @@ -54801,8 +55458,8 @@ var ts; return false; } break; - case 227 /* SwitchStatement */: - if (node.kind === 224 /* BreakStatement */ && !node.label) { + case 230 /* SwitchStatement */: + if (node.kind === 227 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -54817,13 +55474,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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 === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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); @@ -54836,7 +55493,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 === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { + if (node.name.kind === 183 /* ArrayBindingPattern */ || node.name.kind === 182 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -54850,14 +55507,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { + if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -54868,7 +55525,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -54878,19 +55535,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 /* 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 && !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -54945,15 +55602,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return false; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -54963,7 +55620,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -55030,7 +55687,7 @@ var ts; return true; } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* 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; } @@ -55067,13 +55724,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - 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 */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 240 /* TypeAliasDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 253 /* ExportDeclaration */ || + node.kind === 252 /* ExportAssignment */ || + node.kind === 245 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -55082,7 +55739,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 214 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 217 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -55109,7 +55766,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 === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -55131,10 +55788,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, 178 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -55189,8 +55846,8 @@ var ts; /** 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 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -55198,14 +55855,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245 /* ImportClause */: // For default import - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: // For rename import `x as y` + case 248 /* ImportClause */: // For default import + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* 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 === 248 /* ImportSpecifier */; + return decl.parent.kind === 251 /* ImportSpecifier */; default: return false; } @@ -55221,8 +55878,12 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448 /* Literal */); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -55388,7 +56049,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 /* Node */ | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -55481,10 +56142,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 303 /* CommaListExpression */ ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147 /* ComputedPropertyName */); @@ -55847,14 +56507,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169 /* OptionalType */); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170 /* RestType */); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -55862,7 +56546,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -55881,7 +56565,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171 /* ConditionalType */); + var node = createSynthesizedNode(173 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -55899,7 +56583,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172 /* InferType */); + var node = createSynthesizedNode(174 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -55911,7 +56595,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179 /* ImportType */); + var node = createSynthesizedNode(181 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -55929,7 +56613,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173 /* ParenthesizedType */); + var node = createSynthesizedNode(175 /* ParenthesizedType */); node.type = type; return node; } @@ -55941,11 +56625,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174 /* ThisType */); + return createSynthesizedNode(176 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175 /* TypeOperator */); + var node = createSynthesizedNode(177 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -55956,7 +56640,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176 /* IndexedAccessType */); + var node = createSynthesizedNode(178 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -55970,7 +56654,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177 /* MappedType */); + var node = createSynthesizedNode(179 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -55988,7 +56672,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178 /* LiteralType */); + var node = createSynthesizedNode(180 /* LiteralType */); node.literal = literal; return node; } @@ -56001,7 +56685,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ObjectBindingPattern */); + var node = createSynthesizedNode(182 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56013,7 +56697,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181 /* ArrayBindingPattern */); + var node = createSynthesizedNode(183 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56025,7 +56709,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182 /* BindingElement */); + var node = createSynthesizedNode(184 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -56044,7 +56728,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -56058,7 +56742,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -56072,7 +56756,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185 /* PropertyAccessExpression */); + var node = createSynthesizedNode(187 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -56089,7 +56773,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186 /* ElementAccessExpression */); + var node = createSynthesizedNode(188 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -56103,7 +56787,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* CallExpression */); + var node = createSynthesizedNode(189 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -56119,7 +56803,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188 /* NewExpression */); + var node = createSynthesizedNode(190 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -56135,7 +56819,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -56158,7 +56842,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190 /* TypeAssertionExpression */); + var node = createSynthesizedNode(192 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -56172,7 +56856,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191 /* ParenthesizedExpression */); + var node = createSynthesizedNode(193 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -56184,7 +56868,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192 /* FunctionExpression */); + var node = createSynthesizedNode(194 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -56208,7 +56892,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193 /* ArrowFunction */); + var node = createSynthesizedNode(195 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -56242,7 +56926,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194 /* DeleteExpression */); + var node = createSynthesizedNode(196 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56254,7 +56938,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195 /* TypeOfExpression */); + var node = createSynthesizedNode(197 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56266,7 +56950,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196 /* VoidExpression */); + var node = createSynthesizedNode(198 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56278,7 +56962,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197 /* AwaitExpression */); + var node = createSynthesizedNode(199 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56290,7 +56974,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -56303,7 +56987,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -56316,7 +57000,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200 /* BinaryExpression */); + var node = createSynthesizedNode(202 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -56333,7 +57017,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201 /* ConditionalExpression */); + var node = createSynthesizedNode(203 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -56363,7 +57047,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202 /* TemplateExpression */); + var node = createSynthesizedNode(204 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -56401,7 +57085,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203 /* YieldExpression */); + var node = createSynthesizedNode(205 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -56415,7 +57099,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204 /* SpreadElement */); + var node = createSynthesizedNode(206 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -56427,7 +57111,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205 /* ClassExpression */); + var node = createSynthesizedNode(207 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56448,11 +57132,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206 /* OmittedExpression */); + return createSynthesizedNode(208 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -56466,7 +57150,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208 /* AsExpression */); + var node = createSynthesizedNode(210 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -56480,7 +57164,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209 /* NonNullExpression */); + var node = createSynthesizedNode(211 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -56492,7 +57176,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210 /* MetaProperty */); + var node = createSynthesizedNode(212 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -56506,7 +57190,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211 /* TemplateSpan */); + var node = createSynthesizedNode(214 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -56520,25 +57204,18 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212 /* SemicolonClassElement */); + return createSynthesizedNode(215 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213 /* Block */); + var block = createSynthesizedNode(216 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - /* @internal */ - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216 /* ExpressionStatement */); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -56546,7 +57223,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214 /* VariableStatement */); + var node = createSynthesizedNode(217 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -56561,21 +57238,27 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215 /* EmptyStatement */); + return createSynthesizedNode(218 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + ts.createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217 /* IfStatement */); + var node = createSynthesizedNode(220 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -56591,7 +57274,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218 /* DoStatement */); + var node = createSynthesizedNode(221 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -56605,7 +57288,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219 /* WhileStatement */); + var node = createSynthesizedNode(222 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -56619,7 +57302,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220 /* ForStatement */); + var node = createSynthesizedNode(223 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -56637,7 +57320,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForInStatement */); + var node = createSynthesizedNode(224 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -56653,7 +57336,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222 /* ForOfStatement */); + var node = createSynthesizedNode(225 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -56671,7 +57354,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223 /* ContinueStatement */); + var node = createSynthesizedNode(226 /* ContinueStatement */); node.label = asName(label); return node; } @@ -56683,7 +57366,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224 /* BreakStatement */); + var node = createSynthesizedNode(227 /* BreakStatement */); node.label = asName(label); return node; } @@ -56695,7 +57378,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225 /* ReturnStatement */); + var node = createSynthesizedNode(228 /* ReturnStatement */); node.expression = expression; return node; } @@ -56707,7 +57390,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226 /* WithStatement */); + var node = createSynthesizedNode(229 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -56721,7 +57404,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227 /* SwitchStatement */); + var node = createSynthesizedNode(230 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -56735,7 +57418,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228 /* LabeledStatement */); + var node = createSynthesizedNode(231 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -56749,7 +57432,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229 /* ThrowStatement */); + var node = createSynthesizedNode(232 /* ThrowStatement */); node.expression = expression; return node; } @@ -56761,7 +57444,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230 /* TryStatement */); + var node = createSynthesizedNode(233 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -56777,11 +57460,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231 /* DebuggerStatement */); + return createSynthesizedNode(234 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232 /* VariableDeclaration */); + var node = createSynthesizedNode(235 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -56798,7 +57481,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(233 /* VariableDeclarationList */); + var node = createSynthesizedNode(236 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -56811,7 +57494,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234 /* FunctionDeclaration */); + var node = createSynthesizedNode(237 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -56837,7 +57520,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* ClassDeclaration */); + var node = createSynthesizedNode(238 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56859,7 +57542,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236 /* InterfaceDeclaration */); + var node = createSynthesizedNode(239 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56881,7 +57564,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56901,7 +57584,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238 /* EnumDeclaration */); + var node = createSynthesizedNode(241 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56920,7 +57603,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* ModuleDeclaration */); + var node = createSynthesizedNode(242 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -56939,7 +57622,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240 /* ModuleBlock */); + var node = createSynthesizedNode(243 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -56951,7 +57634,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241 /* CaseBlock */); + var node = createSynthesizedNode(244 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -56963,7 +57646,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -56975,7 +57658,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56993,7 +57676,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244 /* ImportDeclaration */); + var node = createSynthesizedNode(247 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -57011,7 +57694,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245 /* ImportClause */); + var node = createSynthesizedNode(248 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -57025,7 +57708,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246 /* NamespaceImport */); + var node = createSynthesizedNode(249 /* NamespaceImport */); node.name = name; return node; } @@ -57037,7 +57720,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247 /* NamedImports */); + var node = createSynthesizedNode(250 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -57049,7 +57732,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248 /* ImportSpecifier */); + var node = createSynthesizedNode(251 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -57063,7 +57746,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249 /* ExportAssignment */); + var node = createSynthesizedNode(252 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -57080,7 +57763,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ExportDeclaration */); + var node = createSynthesizedNode(253 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -57098,7 +57781,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251 /* NamedExports */); + var node = createSynthesizedNode(254 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -57110,7 +57793,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252 /* ExportSpecifier */); + var node = createSynthesizedNode(255 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -57125,7 +57808,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254 /* ExternalModuleReference */); + var node = createSynthesizedNode(257 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -57138,7 +57821,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255 /* JsxElement */); + var node = createSynthesizedNode(258 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -57154,7 +57837,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57170,7 +57853,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257 /* JsxOpeningElement */); + var node = createSynthesizedNode(260 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57186,7 +57869,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258 /* JsxClosingElement */); + var node = createSynthesizedNode(261 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -57198,7 +57881,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259 /* JsxFragment */); + var node = createSynthesizedNode(262 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -57214,7 +57897,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262 /* JsxAttribute */); + var node = createSynthesizedNode(265 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -57228,7 +57911,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263 /* JsxAttributes */); + var node = createSynthesizedNode(266 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -57240,7 +57923,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -57252,7 +57935,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265 /* JsxExpression */); + var node = createSynthesizedNode(268 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -57266,7 +57949,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266 /* CaseClause */); + var node = createSynthesizedNode(269 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -57280,7 +57963,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267 /* DefaultClause */); + var node = createSynthesizedNode(270 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -57292,7 +57975,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268 /* HeritageClause */); + var node = createSynthesizedNode(271 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -57305,7 +57988,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269 /* CatchClause */); + var node = createSynthesizedNode(272 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -57320,7 +58003,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270 /* PropertyAssignment */); + var node = createSynthesizedNode(273 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -57335,7 +58018,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -57349,7 +58032,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272 /* SpreadAssignment */); + var node = createSynthesizedNode(275 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -57362,7 +58045,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273 /* EnumMember */); + var node = createSynthesizedNode(276 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -57383,7 +58066,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274 /* SourceFile */); + var updated = createSynthesizedNode(277 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -57467,7 +58150,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301 /* NotEmittedStatement */); + var node = createSynthesizedNode(304 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -57479,7 +58162,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(308 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57491,7 +58174,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(307 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57506,7 +58189,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(302 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(305 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -57522,7 +58205,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 === 303 /* CommaListExpression */) { + if (node.kind === 306 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -57532,7 +58215,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303 /* CommaListExpression */); + var node = createSynthesizedNode(306 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -57545,14 +58228,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275 /* Bundle */); + var node = ts.createNode(278 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276 /* UnparsedSource */); + var node = ts.createNode(279 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -57560,7 +58243,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277 /* InputFiles */); + var node = ts.createNode(280 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -57703,7 +58386,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 === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -58214,7 +58897,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -58232,13 +58915,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -58265,7 +58948,7 @@ var ts; } else { switch (callee.kind) { - case 185 /* PropertyAccessExpression */: { + case 187 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58278,7 +58961,7 @@ var ts; } break; } - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58338,9 +59021,9 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -58665,7 +59348,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 === 191 /* ParenthesizedExpression */) { + if (skipped.kind === 193 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -58699,8 +59382,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(200 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -58709,7 +59392,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 203 /* YieldExpression */) { + && operand.kind === 205 /* YieldExpression */) { return false; } return true; @@ -58797,7 +59480,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -58812,7 +59495,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -58826,8 +59509,7 @@ 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 === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 303 /* CommaListExpression */ + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } @@ -58845,10 +59527,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 /* ClassExpression */ || - check.kind === 192 /* FunctionExpression */ || - check.kind === 303 /* CommaListExpression */ || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) + return check.kind === 207 /* ClassExpression */ || + check.kind === 194 /* FunctionExpression */ || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -58862,9 +59543,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.createParen(expression); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -58887,7 +59568,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -58925,7 +59606,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -58936,27 +59617,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { + if (kind === 194 /* FunctionExpression */ || kind === 195 /* 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 === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { + if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: return ts.createParenthesizedType(member); @@ -58967,8 +59648,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 172 /* InferType */: + case 177 /* TypeOperator */: + case 174 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -58994,25 +59675,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: node = node.operand; continue; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: node = node.left; continue; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: node = node.condition; continue; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: - node = node.expression; - continue; - case 302 /* PartiallyEmittedExpression */: + case 210 /* AsExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 211 /* NonNullExpression */: + case 305 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -59020,12 +59701,17 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || + node.kind === 306 /* CommaListExpression */; + } + ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; @@ -59036,13 +59722,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 209 /* NonNullExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 211 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -59067,7 +59753,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { node = node.expression; } return node; @@ -59075,11 +59761,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - 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 302 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -59097,7 +59783,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 191 /* ParenthesizedExpression */ + return node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -59162,10 +59848,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -59284,7 +59970,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -59296,11 +59982,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -59333,11 +60019,11 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 204 /* SpreadElement */: - case 272 /* SpreadAssignment */: + case 206 /* SpreadElement */: + case 275 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -59349,7 +60035,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -59361,7 +60047,7 @@ var ts; : propertyName; } break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -59373,7 +60059,7 @@ var ts; : propertyName; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -59391,13 +60077,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -59437,11 +60123,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -59565,7 +60251,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -59602,7 +60288,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { return node; } switch (kind) { @@ -59657,217 +60343,221 @@ var ts; case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168 /* TupleType */: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* UnionType */: + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 169 /* OptionalType */: + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* RestType */: + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 171 /* ConditionalType */: + case 173 /* 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 172 /* InferType */: + case 174 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179 /* ImportType */: + case 181 /* 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 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177 /* MappedType */: + case 179 /* 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 178 /* LiteralType */: + case 180 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182 /* BindingElement */: + case 184 /* 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 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* FunctionExpression */: + case 194 /* 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 193 /* ArrowFunction */: + case 195 /* 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 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201 /* ConditionalExpression */: + case 203 /* 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 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 213 /* Block */: + case 216 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 216 /* ExpressionStatement */: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* IfStatement */: + case 219 /* ExpressionStatement */: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* 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 218 /* DoStatement */: + case 221 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: + case 224 /* 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 222 /* ForOfStatement */: + case 225 /* 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 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234 /* FunctionDeclaration */: + case 237 /* 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 235 /* ClassDeclaration */: + case 238 /* 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 236 /* InterfaceDeclaration */: + case 239 /* 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 237 /* TypeAliasDeclaration */: + case 240 /* 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 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250 /* ExportDeclaration */: + case 253 /* 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 251 /* NamedExports */: + case 254 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -59913,17 +60603,17 @@ var ts; return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 212 /* SemicolonClassElement */: - case 215 /* EmptyStatement */: - case 206 /* OmittedExpression */: - case 231 /* DebuggerStatement */: - case 301 /* NotEmittedStatement */: + case 215 /* SemicolonClassElement */: + case 218 /* EmptyStatement */: + case 208 /* OmittedExpression */: + case 234 /* DebuggerStatement */: + case 304 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -59990,49 +60680,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* NewExpression */: + case 190 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -60040,123 +60730,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ArrowFunction */: + case 195 /* 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 191 /* ParenthesizedExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208 /* AsExpression */: + case 210 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 213 /* Block */: + case 216 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219 /* WhileStatement */: - case 226 /* WithStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60165,7 +60855,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60173,139 +60863,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -60378,7 +61068,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 !== 207 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -60622,7 +61312,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -60769,7 +61458,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -60815,7 +61504,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -60823,13 +61512,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + case 246 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -60859,13 +61548,13 @@ var ts; } } break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -60873,7 +61562,7 @@ var ts; } } break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -60893,7 +61582,7 @@ var ts; } } break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -61509,13 +62198,14 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -61539,14 +62229,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* 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 === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -61574,16 +62264,18 @@ var ts; */ function saveStateAndInvoke(node, f) { // Save state - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } /** @@ -61593,15 +62285,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 240 /* ModuleBlock */: - case 213 /* Block */: - currentScope = node; + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 243 /* ModuleBlock */: + case 216 /* Block */: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -61613,7 +62306,11 @@ 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 === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } + if (ts.isClassDeclaration(node)) { + // XXX: should probably also cover interfaces and type aliases that can have type variables? + currentNameScope = node; } break; } @@ -61657,10 +62354,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -61681,13 +62378,13 @@ var ts; return node; } switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -61707,11 +62404,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 250 /* ExportDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 245 /* ImportClause */ || - (node.kind === 243 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 254 /* ExternalModuleReference */)) { + if (node.kind === 253 /* ExportDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 248 /* ImportClause */ || + (node.kind === 246 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 257 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -61753,7 +62450,7 @@ var ts; case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -61794,6 +62491,8 @@ var ts; // TypeScript accessibility and readonly modifiers are elided. case 167 /* ArrayType */: case 168 /* TupleType */: + case 169 /* OptionalType */: + case 170 /* RestType */: case 166 /* TypeLiteral */: case 161 /* TypePredicate */: case 148 /* TypeParameter */: @@ -61809,36 +62508,36 @@ var ts; 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 */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 175 /* ParenthesizedType */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: // TypeScript type nodes are elided. case 160 /* IndexSignature */: // TypeScript index signatures are elided. case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; 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 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; case 155 /* Constructor */: return visitConstructor(node); - case 236 /* InterfaceDeclaration */: + case 239 /* 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61849,7 +62548,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61860,13 +62559,13 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); case 154 /* MethodDeclaration */: @@ -61879,13 +62578,13 @@ var ts; case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case 149 /* Parameter */: @@ -61898,35 +62597,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -61962,7 +62661,7 @@ var ts; var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) @@ -62005,7 +62704,7 @@ var ts; var statements = [classStatement]; // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -62366,7 +63065,7 @@ var ts; // // super(...arguments); // - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } // Add the property initializers. Transforms this: @@ -62408,7 +63107,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -62445,7 +63144,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -62492,7 +63191,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -62795,7 +63494,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } /** @@ -62922,8 +63621,8 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -62945,8 +63644,8 @@ var ts; return serializeTypeNode(node.type); case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: @@ -63034,7 +63733,7 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return serializeTypeNode(node.type); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -63049,7 +63748,7 @@ var ts; return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -63069,18 +63768,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: return serializeUnionOrIntersectionType(node); case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: case 142 /* UnknownKeyword */: - case 174 /* ThisType */: - case 179 /* ImportType */: + case 176 /* ThisType */: + case 181 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63093,7 +63792,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -63132,7 +63831,7 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); @@ -63179,7 +63878,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. + name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -63513,7 +64212,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -63594,7 +64293,7 @@ var ts; * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -63618,7 +64317,7 @@ var ts; // enum body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63643,7 +64342,7 @@ var ts; // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63691,7 +64390,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } /** * Transforms the value of an enum member. @@ -63769,12 +64468,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 === 274 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 277 /* 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 === 238 /* EnumDeclaration */) { + if (node.kind === 241 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -63836,7 +64535,7 @@ var ts; // module body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63860,7 +64559,7 @@ var ts; // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63893,7 +64592,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240 /* ModuleBlock */) { + if (body.kind === 243 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -63939,13 +64638,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 !== 240 /* ModuleBlock */) { + if (body.kind !== 243 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -63986,7 +64685,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 246 /* NamespaceImport */) { + if (node.kind === 249 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -64141,17 +64840,17 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -64218,16 +64917,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(271 /* ShorthandPropertyAssignment */); + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(239 /* ModuleDeclaration */); + context.enableEmitNotification(242 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; } /** * Hook for node emit. @@ -64288,9 +64987,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -64328,9 +65027,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 !== 274 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); + if (container && container.kind !== 277 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -64465,15 +65164,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -64482,27 +65181,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - 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 */: + case 216 /* Block */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 229 /* WithStatement */: + case 231 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -64537,7 +65236,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -64703,7 +65402,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 === 193 /* ArrowFunction */; + var isArrowFunction = node.kind === 195 /* 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 @@ -64776,11 +65475,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -64824,11 +65523,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -64860,7 +65559,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -64959,25 +65658,25 @@ var ts; return node; } switch (node.kind) { - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitVoidExpression(node); case 155 /* Constructor */: return visitConstructorDeclaration(node); @@ -64987,19 +65686,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); case 149 /* Parameter */: return visitParameter(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -65033,7 +65732,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -65045,7 +65744,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 === 272 /* SpreadAssignment */) { + if (e.kind === 275 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -65054,7 +65753,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -65072,7 +65771,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 !== 184 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -65211,13 +65910,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -65385,11 +66084,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -65433,11 +66132,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -65469,7 +66168,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -65582,13 +66281,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -65598,13 +66297,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -65679,7 +66378,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265 /* JsxExpression */) { + else if (node.kind === 268 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -65773,7 +66472,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255 /* JsxElement */) { + if (node.kind === 258 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -66079,7 +66778,7 @@ var ts; return node; } switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66312,13 +67011,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 225 /* ReturnStatement */ + && node.kind === 228 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -66346,63 +67045,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return visitClassExpression(node); case 149 /* Parameter */: return visitParameter(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -66413,28 +67112,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitMetaProperty(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -66521,14 +67220,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 === 224 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -66539,7 +67238,7 @@ var ts; } } else { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -66656,7 +67355,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -66720,7 +67419,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), /*location*/ extendsClauseElement)); } } @@ -66839,11 +67538,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 225 /* ReturnStatement */) { + if (statement.kind === 228 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 217 /* IfStatement */) { + else if (statement.kind === 220 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -66851,7 +67550,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 213 /* Block */) { + else if (statement.kind === 216 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -66909,7 +67608,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -66919,8 +67618,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 /* BinaryExpression */ - || superCallExpression.left.kind !== 187 /* CallExpression */) { + if (superCallExpression.kind !== 202 /* BinaryExpression */ + || superCallExpression.left.kind !== 189 /* 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. @@ -67035,7 +67734,7 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -67049,7 +67748,7 @@ var ts; function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -67101,7 +67800,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ - ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) @@ -67117,7 +67816,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -67137,7 +67836,7 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return statements; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -67151,8 +67850,8 @@ var ts; // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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()); @@ -67183,7 +67882,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: @@ -67227,7 +67926,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -67245,7 +67944,7 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); + var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. @@ -67388,7 +68087,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 === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -67433,7 +68132,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193 /* ArrowFunction */); + ts.Debug.assert(node.kind === 195 /* 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 @@ -67501,10 +68200,10 @@ 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 191 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + case 193 /* ParenthesizedExpression */: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 202 /* BinaryExpression */: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); } @@ -67522,9 +68221,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 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -67566,7 +68265,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -67725,14 +68424,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -67790,11 +68489,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -67883,13 +68582,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -67988,11 +68687,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -68156,7 +68855,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -68173,7 +68872,7 @@ var ts; ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { @@ -68282,10 +68981,10 @@ var ts; case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -68537,7 +69236,7 @@ var ts; statements.push(funcStatements[classBodyStart]); classBodyStart++; // Add the class alias following the declaration. - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } // Find the trailing 'return' statement (4) while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { @@ -68674,7 +69373,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -68941,9 +69640,9 @@ var ts; context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(193 /* ArrowFunction */); - context.enableEmitNotification(192 /* FunctionExpression */); - context.enableEmitNotification(234 /* FunctionDeclaration */); + context.enableEmitNotification(195 /* ArrowFunction */); + context.enableEmitNotification(194 /* FunctionExpression */); + context.enableEmitNotification(237 /* FunctionDeclaration */); } } /** @@ -68984,10 +69683,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 235 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -69069,11 +69768,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -69081,7 +69780,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -69134,15 +69833,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257 /* JsxOpeningElement */); - context.enableEmitNotification(258 /* JsxClosingElement */); - context.enableEmitNotification(256 /* JsxSelfClosingElement */); + context.enableEmitNotification(260 /* JsxOpeningElement */); + context.enableEmitNotification(261 /* JsxClosingElement */); + context.enableEmitNotification(259 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(270 /* PropertyAssignment */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(273 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -69161,9 +69860,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -69495,13 +70194,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -69514,24 +70213,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return visitBreakStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return visitContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -69552,21 +70251,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitConditionalExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69579,9 +70278,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -69757,7 +70456,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } /** @@ -69809,7 +70508,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -69821,7 +70520,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -69945,7 +70644,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* Statement */, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -70098,7 +70797,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -70197,35 +70896,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: return transformAndEmitBlock(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return transformAndEmitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return transformAndEmitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return transformAndEmitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return transformAndEmitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -70262,7 +70961,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -70413,7 +71112,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -70423,7 +71122,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -70484,7 +71183,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); @@ -70507,7 +71206,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -70655,7 +71354,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -70668,7 +71367,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -71531,7 +72230,7 @@ var ts; // indicate entry into a protected region by pushing the label numbers // for each block in the protected region. var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, [ ts.createArrayLiteral([ createLabel(startLabel), @@ -71545,7 +72244,7 @@ var ts; if (markLabelEnd) { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -71703,7 +72402,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -71897,11 +72596,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported 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.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(277 /* 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. @@ -71994,7 +72693,7 @@ var ts; // // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, + ts.createExpressionStatement(ts.createCall(define, /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ // Add the dependency array argument: // @@ -72045,9 +72744,9 @@ var ts; ts.createIdentifier("exports") ])) ]), - ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -72071,7 +72770,7 @@ var ts; // } // })(function ...) var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, + ts.createExpressionStatement(ts.createCall(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // @@ -72150,7 +72849,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. @@ -72205,7 +72904,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); @@ -72223,23 +72922,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -72266,17 +72965,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -72370,7 +73069,7 @@ var ts; ts.createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; @@ -72465,7 +73164,7 @@ var ts; if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -72533,7 +73232,7 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( @@ -72546,7 +73245,7 @@ var ts; } else { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -72585,13 +73284,13 @@ var ts; for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { // export * from "mod"; - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } /** @@ -72697,7 +73396,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -72758,7 +73457,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -72813,10 +73512,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -72946,10 +73645,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), @@ -72970,7 +73669,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, location, allowComments) { - var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -73015,7 +73714,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -73079,10 +73778,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -73103,7 +73802,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -73178,7 +73877,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -73254,11 +73953,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - 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. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(277 /* 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. @@ -73320,7 +74019,7 @@ var ts; var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) @@ -73479,7 +74178,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -73504,7 +74203,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250 /* ExportDeclaration */) { + if (externalImport.kind !== 253 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -73558,9 +74257,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) ])), - ts.createStatement(ts.createCall(exportFunction, + ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) ], /*multiline*/ true)); } @@ -73582,19 +74281,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -73610,7 +74309,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { @@ -73619,7 +74318,7 @@ var ts; // emit as: // // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, /*typeArguments*/ undefined, [parameterName]))); } break; @@ -73644,15 +74343,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -73753,7 +74452,7 @@ var ts; var name = ts.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -73790,7 +74489,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -73828,7 +74527,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 === 274 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 277 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -73892,7 +74591,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 === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -73954,10 +74653,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -74109,7 +74808,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -74137,43 +74836,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitDefaultClause(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitTryStatement(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -74356,7 +75055,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 200 /* BinaryExpression */) { + && node.kind === 202 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -74421,7 +75120,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274 /* SourceFile */; + return container !== undefined && container.kind === 277 /* SourceFile */; } else { return false; @@ -74454,7 +75153,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -74502,7 +75201,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -74538,10 +75237,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -74634,14 +75333,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* 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 === 199 /* PostfixUnaryExpression */) { + if (node.kind === 201 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -74663,7 +75362,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -74702,7 +75401,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274 /* SourceFile */); + context.enableEmitNotification(277 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -74731,10 +75430,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -74841,7 +75540,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74870,7 +75569,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74917,7 +75616,7 @@ var ts; 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 === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* 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 : @@ -74936,7 +75635,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 === 235 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 238 /* 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 : @@ -75027,7 +75726,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -75041,7 +75740,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234 /* FunctionDeclaration */: + case 237 /* 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 : @@ -75097,7 +75796,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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 : @@ -75110,7 +75809,7 @@ 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 163 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -75125,10 +75824,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159 /* ConstructSignature */: @@ -75142,17 +75841,17 @@ var ts; 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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -75167,7 +75866,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 235 /* ClassDeclaration */) { + if (node.parent.parent.kind === 238 /* 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 : @@ -75264,7 +75963,13 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + // If it is visible via `// `, then we should just use that + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -75319,10 +76024,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -75350,7 +76055,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -75448,7 +76153,7 @@ var ts; return name; } else { - if (name.kind === 181 /* ArrayBindingPattern */) { + if (name.kind === 183 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -75456,7 +76161,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206 /* OmittedExpression */) { + if (elem.kind === 208 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -75514,7 +76219,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 /* Parameter */ @@ -75536,20 +76241,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return false; } return false; @@ -75603,7 +76308,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -75615,7 +76320,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -75642,7 +76347,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 === 246 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 249 /* 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; @@ -75747,14 +76452,14 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* 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 207 /* ExpressionWithTypeArguments */: { + case 209 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -75808,7 +76513,7 @@ var ts; return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -75822,7 +76527,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171 /* ConditionalType */: { + case 173 /* 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); @@ -75840,7 +76545,7 @@ var ts; case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179 /* ImportType */: { + case 181 /* 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)); @@ -75879,7 +76584,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250 /* ExportDeclaration */: { + case 253 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -75888,7 +76593,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -75918,10 +76623,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -75942,24 +76647,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 240 /* 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 236 /* InterfaceDeclaration */: { + case 239 /* 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 234 /* FunctionDeclaration */: { + case 237 /* 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 239 /* ModuleDeclaration */: { + case 242 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240 /* ModuleBlock */) { + if (inner && inner.kind === 243 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -75980,7 +76685,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 235 /* ClassDeclaration */: { + case 238 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -76020,7 +76725,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(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"); // TODO: GH#18217 @@ -76050,10 +76755,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238 /* EnumDeclaration */: { + case 241 /* 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; @@ -76072,7 +76777,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239 /* ModuleDeclaration */) { + if (input.kind === 242 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -76093,7 +76798,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206 /* OmittedExpression */) { + if (e.kind === 208 /* OmittedExpression */) { return; } if (e.name) { @@ -76147,7 +76852,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 === 274 /* SourceFile */; + var parentIsFile = node.parent.kind === 277 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -76168,7 +76873,7 @@ var ts; var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3 /* MultiLineCommentTrivia */) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -76182,7 +76887,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -76195,7 +76900,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* InterfaceDeclaration */) { return true; } return false; @@ -76224,7 +76929,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: @@ -76234,17 +76939,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - 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 */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 217 /* VariableStatement */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return true; } return false; @@ -76261,14 +76966,14 @@ var ts; case 153 /* MethodSignature */: case 158 /* CallSignature */: case 160 /* IndexSignature */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 148 /* TypeParameter */: - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: case 162 /* TypeReference */: - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 179 /* ImportType */: + case 181 /* ImportType */: return true; } return false; @@ -76344,7 +77049,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(306 /* Count */); + var enabledSyntaxKindFeatures = new Array(309 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -76679,7 +77384,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap @@ -76689,7 +77393,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 277 /* 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)); @@ -76780,7 +77484,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** * Emits a mapping. @@ -76840,6 +77543,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -76850,50 +77554,55 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { // empty } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); // First, decode the old component sourcemap - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -76910,7 +77619,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -76965,13 +77674,15 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - // 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 - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + // 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 + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -77087,7 +77798,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 304 /* 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 */; @@ -77108,7 +77819,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 === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -77450,7 +78161,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275 /* Bundle */) { + if (sourceFile.kind === 278 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; @@ -77585,6 +78296,11 @@ var ts; // Setup and perform the transformation to retrieve declarations from the input files var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + // Checker wont collect the linked aliases since thats only done when declaration is enabled. + // Do that here when emitting only dts files + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -77612,9 +78328,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71 /* Identifier */) { + resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -77714,9 +78443,9 @@ var ts; break; } switch (node.kind) { - case 274 /* SourceFile */: return printFile(node); - case 275 /* Bundle */: return printBundle(node); - case 276 /* UnparsedSource */: return printUnparsedSource(node); + case 277 /* SourceFile */: return printFile(node); + case 278 /* Bundle */: return printBundle(node); + case 279 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -77861,7 +78590,7 @@ var ts; } return pipelineEmitWithoutComments; case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { return pipelineEmitWithSourceMap; } // falls through @@ -77887,7 +78616,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); + ts.Debug.assert(hint !== 0 /* SourceFile */); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -77906,7 +78635,7 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 276 /* UnparsedSource */: + case 279 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: @@ -77951,7 +78680,7 @@ var ts; return emitTypeReference(node); case 163 /* FunctionType */: return emitFunctionType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 164 /* ConstructorType */: return emitConstructorType(node); @@ -77963,178 +78692,181 @@ var ts; return emitArrayType(node); case 168 /* TupleType */: return emitTupleType(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return emitOptionalType(node); + case 171 /* UnionType */: return emitUnionType(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return emitIntersectionType(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return emitConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return emitInferType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return emitParenthesizedType(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return emitThisType(); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return emitTypeOperator(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return emitMappedType(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return emitLiteralType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return emitImportTypeNode(node); - case 279 /* JSDocAllType */: + case 282 /* JSDocAllType */: write("*"); return; - case 280 /* JSDocUnknownType */: + case 283 /* JSDocUnknownType */: write("?"); return; - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 285 /* JSDocVariadicType */: - return emitJSDocVariadicType(node); + case 170 /* RestType */: + case 288 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return emitBindingElement(node); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return emitTemplateSpan(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 213 /* Block */: + case 216 /* Block */: return emitBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return emitVariableStatement(node); - case 215 /* EmptyStatement */: + case 218 /* EmptyStatement */: return emitEmptyStatement(); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return emitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return emitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return emitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return emitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return emitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return emitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return emitForOfStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return emitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return emitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return emitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return emitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return emitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return emitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return emitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return emitTryStatement(node); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return emitClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return emitModuleBlock(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return emitCaseBlock(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return emitImportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return emitImportClause(node); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return emitNamespaceImport(node); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return emitNamedImports(node); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return emitImportSpecifier(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return emitExportDeclaration(node); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return emitNamedExports(node); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return emitExportSpecifier(node); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return; // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 258 /* JsxClosingElement */: - case 261 /* JsxClosingFragment */: + case 261 /* JsxClosingElement */: + case 264 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return emitJsxAttribute(node); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return emitJsxAttributes(node); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return emitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return emitDefaultClause(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return emitHeritageClause(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -78169,71 +78901,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return emitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return emitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return emitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return emitArrowFunction(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return emitDeleteExpression(node); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return emitVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return emitAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return emitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return emitConditionalExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return emitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return emitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return emitSpreadExpression(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return emitClassExpression(node); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: return emitAsExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return emitNonNullExpression(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return emitJsxElement(node); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return emitCommaList(node); } } @@ -78250,7 +78982,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 /* Bundle */ ? node : undefined; + var bundle = node.kind === 278 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -78376,7 +79108,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -78545,7 +79277,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -78554,6 +79286,10 @@ var ts; emitList(node, node.elementTypes, 272 /* TupleTypeElements */); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260 /* UnionTypeConstituents */); } @@ -78835,7 +79571,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 === 198 /* PrefixUnaryExpression */ + return operand.kind === 200 /* 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 */))); } @@ -78955,7 +79691,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217 /* IfStatement */) { + if (node.elseStatement.kind === 220 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -79026,7 +79762,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { emit(node); } else { @@ -79128,7 +79864,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272 /* VariableDeclarationList */); } @@ -79321,7 +80057,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239 /* ModuleDeclaration */) { + while (body.kind === 242 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -80246,7 +80982,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -80311,81 +81047,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: ts.forEach(node.statements, generateNames); break; - case 228 /* LabeledStatement */: - case 226 /* WithStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 231 /* LabeledStatement */: + case 229 /* WithStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: generateNames(node.statement); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: generateNames(node.declarationList); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: generateNames(node.importClause); break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -80394,8 +81130,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 152 /* PropertyDeclaration */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -80581,17 +81317,17 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 252 /* ExportAssignment */: return generateNameForExportDefault(); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return generateNameForClassExpression(); case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -81252,17 +81988,20 @@ var ts; } return context; } - function formatLocation(file, start, host) { + /* @internal */ + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -81281,11 +82020,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -82012,7 +82751,16 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + // Use local caches + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + // Before falling back to the host + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -82272,10 +83020,10 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: - case 232 /* VariableDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: + case 235 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -82283,41 +83031,41 @@ var ts; } } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268 /* HeritageClause */: + case 271 /* 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 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -82330,25 +83078,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 235 /* ClassDeclaration */: + case 238 /* 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 */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* 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 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); } break; case 152 /* PropertyDeclaration */: @@ -82370,11 +83118,11 @@ var ts; return; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -83040,14 +83788,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -84701,11 +85449,12 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - // Note: fromSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + // Note: importingSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -84718,7 +85467,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); 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); @@ -84736,13 +85485,13 @@ var ts; 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); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } 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); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -84812,11 +85561,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0 /* EqualTo */) { resolvedParts.pop(); originalParts.pop(); } @@ -84850,17 +85600,16 @@ var ts; return [target]; } /** - * Looks for a existing imports that use symlinks to this module. + * Looks for existing imports that use symlinks to this module. * Only if no symlink is available, the real path will be used. */ - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -84936,7 +85685,7 @@ var ts; var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // 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))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); @@ -85344,7 +86093,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; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; 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); @@ -85876,16 +86625,20 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */) ? ".jsx" /* Jsx */ : ".js" /* Js */); + var newExtension = ts.fileExtensionIs(inputFileName, ".json" /* Json */) ? ".json" /* Json */ : + ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -86057,9 +86810,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -86109,7 +86859,7 @@ var ts; // Everything is broken - we don't even know what to watch. Give up. return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { // Watch this file @@ -86136,7 +86886,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -86341,14 +87091,18 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -86356,7 +87110,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -86652,12 +87410,12 @@ var ts; } // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -86726,7 +87484,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; @@ -87184,7 +87942,7 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ - ts.defaultPreferences = {}; + ts.emptyOptions = {}; var TextChange = /** @class */ (function () { function TextChange() { } @@ -87420,35 +88178,35 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 149 /* Parameter */: - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* 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 */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 272 /* CatchClause */: + case 265 /* JsxAttribute */: return 1 /* Value */; case 148 /* TypeParameter */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: case 166 /* TypeLiteral */: return 2 /* Type */; - case 298 /* JSDocTypedefTag */: + case 301 /* 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 273 /* EnumMember */: - case 235 /* ClassDeclaration */: + case 276 /* EnumMember */: + case 238 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -87458,26 +88216,26 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* EnumDeclaration */: - case 247 /* NamedImports */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 241 /* EnumDeclaration */: + case 250 /* NamedImports */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 249 /* ExportAssignment */) { + else if (node.parent.kind === 252 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -87510,7 +88268,7 @@ var ts; // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // 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 */; + return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { while (node.parent.kind === 146 /* QualifiedName */) { @@ -87536,16 +88294,16 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 185 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { + if (root.parent.kind === 187 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -87556,25 +88314,25 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return true; } switch (node.parent.kind) { case 162 /* TypeReference */: return true; - case 179 /* ImportType */: + case 181 /* ImportType */: return !node.parent.isTypeOf; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 189 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 190 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -87587,7 +88345,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -87612,11 +88370,11 @@ var ts; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -87628,20 +88386,20 @@ var ts; switch (node.parent.kind) { case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 273 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 276 /* EnumMember */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return node.parent.argumentExpression === node; case 147 /* ComputedPropertyName */: return true; - case 178 /* LiteralType */: - return node.parent.parent.kind === 176 /* IndexedAccessType */; + case 180 /* LiteralType */: + return node.parent.parent.kind === 178 /* IndexedAccessType */; default: return false; } @@ -87665,17 +88423,17 @@ var ts; return undefined; } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return node; } } @@ -87683,26 +88441,26 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return "class" /* classElement */; - case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 237 /* TypeAliasDeclaration */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 240 /* TypeAliasDeclaration */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 238 /* EnumDeclaration */: return "enum" /* enumElement */; - case 232 /* VariableDeclaration */: + case 241 /* EnumDeclaration */: return "enum" /* enumElement */; + case 235 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return "function" /* functionElement */; case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; @@ -87717,15 +88475,14 @@ var ts; 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 276 /* 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 */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: + case 249 /* NamespaceImport */: return "alias" /* alias */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -87749,11 +88506,13 @@ var ts; return "" /* unknown */; } } + case 71 /* Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; } function getKindOfVariableDeclaration(v) { - return ts.isConst(v) + return ts.isVarConst(v) ? "const" /* constElement */ : ts.isLet(v) ? "let" /* letElement */ @@ -87786,6 +88545,10 @@ var ts; return startEndContainsRange(r1.pos, r1.end, r2); } ts.rangeContainsRange = rangeContainsRange; + function rangeContainsRangeExclusive(r1, r2) { + return rangeContainsPositionExclusive(r1, r2.pos) && rangeContainsPositionExclusive(r1, r2.end); + } + ts.rangeContainsRangeExclusive = rangeContainsRangeExclusive; function rangeContainsPosition(r, pos) { return r.pos <= pos && pos <= r.end; } @@ -87806,6 +88569,10 @@ var ts; return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); } ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function nodeOverlapsWithStartEnd(node, sourceFile, start, end) { + return startEndOverlapsWithStartEnd(node.getStart(sourceFile), node.end, start, end); + } + ts.nodeOverlapsWithStartEnd = nodeOverlapsWithStartEnd; function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { var start = Math.max(start1, start2); var end = Math.min(end1, end2); @@ -87825,28 +88592,28 @@ var ts; return false; } switch (n.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: - case 180 /* ObjectBindingPattern */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: case 166 /* TypeLiteral */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 241 /* CaseBlock */: - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 244 /* CaseBlock */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 188 /* NewExpression */: + case 190 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 187 /* CallExpression */: - case 191 /* ParenthesizedExpression */: - case 173 /* ParenthesizedType */: + case 189 /* CallExpression */: + case 193 /* ParenthesizedExpression */: + case 175 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -87854,13 +88621,13 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 159 /* ConstructSignature */: case 158 /* CallSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -87870,19 +88637,19 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 183 /* ArrayLiteralExpression */: - case 181 /* ArrayBindingPattern */: - case 186 /* ElementAccessExpression */: + case 185 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 188 /* ElementAccessExpression */: case 147 /* ComputedPropertyName */: case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); @@ -87891,44 +88658,44 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 218 /* DoStatement */: + case 221 /* 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 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 195 /* TypeOfExpression */: - case 194 /* DeleteExpression */: - case 196 /* VoidExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: + case 197 /* TypeOfExpression */: + case 196 /* DeleteExpression */: + case 198 /* VoidExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -87992,38 +88759,30 @@ var ts; * position >= start and (position < end or (position === end && token is literal or keyword or identifier)) */ function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, /*includeJsDocComment*/ true, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); + return getTouchingToken(sourceFile, position, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); } ts.getTouchingPropertyName = getTouchingPropertyName; /** * Returns the token if position is in [start, end). * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true */ - function getTouchingToken(sourceFile, position, includeJsDocComment, includePrecedingTokenAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false, includeJsDocComment); + function getTouchingToken(sourceFile, position, includePrecedingTokenAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false); } 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); + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, /*includeEndPosition*/ false); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition, includeJsDocComment) { + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition) { var current = sourceFile; outer: while (true) { - if (ts.isToken(current)) { - // exit early - return current; - } // find the child that contains 'position' for (var _i = 0, _a = current.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; - if (!includeJsDocComment && ts.isJSDocNode(child)) { - continue; - } - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { // If this child begins after position, then all subsequent children will as well. break; @@ -88054,7 +88813,7 @@ var ts; function findTokenOnLeftOfPosition(file, position) { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. - var tokenAtPosition = getTokenAtPosition(file, position, /*includeJsDocComment*/ false); + var tokenAtPosition = getTokenAtPosition(file, position); if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } @@ -88068,19 +88827,14 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - var children = n.getChildren(); - for (var _i = 0, children_3 = children; _i < children_3.length; _i++) { - var child = children_3[_i]; + return ts.firstDefined(n.getChildren(), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || // previous token ends exactly at the beginning of child (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child, sourceFile)) { - return find(child); - } - } - return undefined; + return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find(child) : undefined; + }); } } ts.findNextToken = findNextToken; @@ -88088,7 +88842,7 @@ var ts; * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { + function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) { var result = find(startNode || sourceFile); ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; @@ -88105,7 +88859,7 @@ var ts; // we need to find the last token in a previous child. // 2) `position` is within the same span: we recurse on `child`. if (position < child.end) { - var start = child.getStart(sourceFile, includeJsDoc); + var start = child.getStart(sourceFile, /*includeJsDoc*/ !excludeJsdoc); var lookInPreviousChild = (start >= position) || // cursor in the leading trivia !nodeHasTokens(child, sourceFile) || isWhiteSpaceOnlyJsxText(child); @@ -88120,7 +88874,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 277 /* 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. @@ -88180,7 +88934,7 @@ var ts; * returns true if the position is in between the open and close elements of an JSX expression. */ function isInsideJsxElementOrAttribute(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); if (!token) { return false; } @@ -88192,17 +88946,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { return true; } return false; @@ -88212,7 +88966,7 @@ var ts; return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; } function isInTemplateString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; @@ -88254,7 +89008,7 @@ var ts; if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { - return { called: token, nTypeArguments: nTypeArguments }; + return ts.isDeclarationName(token) ? undefined : { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -88324,19 +89078,13 @@ var ts; * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - function isInComment(sourceFile, position, tokenAtPosition, predicate) { - return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); + function isInComment(sourceFile, position, tokenAtPosition) { + return ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*precedingToken*/ undefined, tokenAtPosition); } ts.isInComment = isInComment; function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*"; - } + var token = getTokenAtPosition(sourceFile, position); + return !!ts.findAncestor(token, ts.isJSDoc); } ts.hasDocComment = hasDocComment; function nodeHasTokens(n, sourceFile) { @@ -88345,7 +89093,7 @@ var ts; return n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node) { - var flags = ts.getCombinedModifierFlags(node); + var flags = ts.isDeclaration(node) ? ts.getCombinedModifierFlags(node) : 0 /* None */; var result = []; if (flags & 8 /* Private */) result.push("private" /* privateMemberModifier */); @@ -88365,10 +89113,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -88413,18 +89161,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 183 /* ArrayLiteralExpression */ || - node.kind === 184 /* ObjectLiteralExpression */) { + if (node.kind === 185 /* ArrayLiteralExpression */ || + node.kind === 186 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 200 /* BinaryExpression */ && + if (node.parent.kind === 202 /* 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 === 222 /* ForOfStatement */ && + if (node.parent.kind === 225 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -88432,7 +89180,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -88440,19 +89188,17 @@ var ts; } ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; function isInReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ true); } ts.isInReferenceComment = isInReferenceComment; function isInNonReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ false); } ts.isInNonReferenceComment = isInNonReferenceComment; + function isInReferenceCommentWorker(sourceFile, position, shouldBeReference) { + var range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined); + return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); + } function createTextSpanFromNode(node, sourceFile) { return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); } @@ -88566,13 +89312,17 @@ var ts; QuotePreference[QuotePreference["Single"] = 0] = "Single"; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); + function quotePreferenceFromString(str, sourceFile) { + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + } + ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference) { return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; } else { - var firstModuleSpecifier = ts.firstOrUndefined(sourceFile.imports); - return !!firstModuleSpecifier && !ts.isStringDoubleQuoted(firstModuleSpecifier, sourceFile) ? 0 /* Single */ : 1 /* Double */; + var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, ts.isStringLiteral); + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; } } ts.getQuotePreference = getQuotePreference; @@ -88652,6 +89402,37 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + var NodeMap = /** @class */ (function () { + function NodeMap() { + this.map = ts.createMap(); + } + NodeMap.prototype.get = function (node) { + var res = this.map.get(String(ts.getNodeId(node))); + return res && res.value; + }; + NodeMap.prototype.getOrUpdate = function (node, setValue) { + var res = this.get(node); + if (res) + return res; + var value = setValue(); + this.set(node, value); + return value; + }; + NodeMap.prototype.set = function (node, value) { + this.map.set(String(ts.getNodeId(node)), { node: node, value: value }); + }; + NodeMap.prototype.has = function (node) { + return this.map.has(String(ts.getNodeId(node))); + }; + NodeMap.prototype.forEach = function (cb) { + this.map.forEach(function (_a) { + var node = _a.node, value = _a.value; + return cb(value, node); + }); + }; + return NodeMap; + }()); + ts.NodeMap = NodeMap; function getParentNodeInSpan(node, file, span) { if (!node) return undefined; @@ -88667,6 +89448,10 @@ var ts; return ts.textSpanContainsPosition(span, node.getStart(file)) && node.getEnd() <= ts.textSpanEnd(span); } + function findModifier(node, kind) { + return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); + } + ts.findModifier = findModifier; /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); @@ -88879,7 +89664,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && + (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -89308,7 +90093,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_5 = dense[i + 1]; + var length_6 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -89317,8 +90102,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_5, classification: convertClassification(type) }); - lastEnd = start + length_5; + entries.push({ length: length_6, classification: convertClassification(type) }); + lastEnd = start + length_6; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -89497,10 +90282,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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -89712,18 +90497,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 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -89810,22 +90595,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -89854,17 +90639,17 @@ var ts; var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 232 /* VariableDeclaration */ || + if (parent.kind === 235 /* VariableDeclaration */ || parent.kind === 152 /* PropertyDeclaration */ || parent.kind === 149 /* Parameter */ || - parent.kind === 262 /* JsxAttribute */) { + parent.kind === 265 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 200 /* BinaryExpression */ || - parent.kind === 198 /* PrefixUnaryExpression */ || - parent.kind === 199 /* PostfixUnaryExpression */ || - parent.kind === 201 /* ConditionalExpression */) { + if (parent.kind === 202 /* BinaryExpression */ || + parent.kind === 200 /* PrefixUnaryExpression */ || + parent.kind === 201 /* PostfixUnaryExpression */ || + parent.kind === 203 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -89875,7 +90660,7 @@ var ts; } else if (tokenKind === 9 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -89891,7 +90676,7 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -89901,17 +90686,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -89963,12 +90748,12 @@ var ts; }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker)); + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; - function getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; + var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); @@ -89980,7 +90765,6 @@ var ts; } } else { - // Check for node modules return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } } @@ -90097,7 +90881,7 @@ var ts; for (var path in paths) { var patterns = paths[path]; if (paths.hasOwnProperty(path) && patterns) { - var _loop_13 = function (name, kind) { + var _loop_12 = function (name, kind) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind)); @@ -90105,7 +90889,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind; - _loop_13(name, kind); + _loop_12(name, kind); } } } @@ -90121,7 +90905,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_14 = function (moduleName) { + var _loop_13 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); @@ -90129,7 +90913,7 @@ var ts; }; for (var _e = 0, _f = enumerateNodeModulesVisibleToScript(host, scriptPath); _e < _f.length; _e++) { var moduleName = _f[_e]; - _loop_14(moduleName); + _loop_13(moduleName); } } if (!foundGlobal) { @@ -90146,14 +90930,16 @@ var ts; function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") && ts.startsWith(path, fragment) ? [{ name: path, kind: "directory" /* directory */ }] : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); - if (!ts.startsWith(fragment, pathPrefix)) { - return [{ name: pathPrefix, kind: "directory" /* directory */ }]; + var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); + return remainingFragment === undefined ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { + return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); + }); + function justPathMappingName(name) { + return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; } - var remainingFragment = fragment.slice(pathPrefix.length); - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { if (!host.readDirectory) { @@ -90210,7 +90996,7 @@ var ts; return nonRelativeModuleNames; } function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { - var token = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, position); var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); var range = commentRanges && ts.find(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end; }); if (!range) { @@ -90683,11 +91469,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.parent.parent.kind) { case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent)), isNewIdentifier: false }; - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -90695,12 +91481,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 179 /* ImportType */: + case 181 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 270 /* PropertyAssignment */: + case 273 /* 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 { @@ -90717,7 +91503,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -90730,8 +91516,8 @@ var ts; } return undefined; } - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -90740,9 +91526,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 254 /* ExternalModuleReference */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 257 /* 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*/"); @@ -90819,7 +91605,7 @@ var ts; || ts.codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) : symbol.name; } - function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, getCanonicalFileName, preferences, cancellationToken) { + function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); var name = entryId.name; @@ -90848,7 +91634,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; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -90891,14 +91677,14 @@ var ts; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, allSourceFiles, preferences) { + function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, allSourceFiles, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || symbolOriginInfo.type !== "export") { return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; 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; + var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, allSourceFiles, formatContext, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { @@ -90939,11 +91725,11 @@ var ts; return getContextualTypeFromParent(previousToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -90953,7 +91739,7 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo @@ -90968,15 +91754,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checker.getContextualType(parent); - case 200 /* BinaryExpression */: { + case 202 /* 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 266 /* CaseClause */: + case 269 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -90992,16 +91778,15 @@ 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 === 274 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); } 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 + var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) log("getCompletionData: Get current token: " + (ts.timestamp() - start)); start = ts.timestamp(); - // Completion not allowed inside comments, bail out if this is the case var insideComment = ts.isInComment(sourceFile, position, currentToken); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); var insideJsDocTagTypeExpression = false; @@ -91044,11 +91829,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { - currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 299 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 302 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -91066,7 +91851,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined); // 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 @@ -91075,7 +91860,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); // TODO: GH#18217 + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); } // Find the node where completion is requested on. @@ -91098,15 +91883,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; case 146 /* QualifiedName */: node = parent.left; break; - case 179 /* ImportType */: - case 210 /* MetaProperty */: + case 181 /* ImportType */: + case 212 /* MetaProperty */: node = parent; break; default: @@ -91119,7 +91904,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 === 185 /* PropertyAccessExpression */) { + if (parent && parent.kind === 187 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -91127,39 +91912,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 200 /* BinaryExpression */: - if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { - // It has a left-hand side, so we're not in an opening JSX tag. + case 202 /* BinaryExpression */: + if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: + case 260 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -91212,11 +91996,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: - case 294 /* JSDocReturnTag */: - case 296 /* JSDocTypeTag */: - case 298 /* JSDocTypedefTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: + case 297 /* JSDocReturnTag */: + case 299 /* JSDocTypeTag */: + case 301 /* JSDocTypedefTag */: return true; default: return false; @@ -91250,7 +92034,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -91274,27 +92058,31 @@ var ts; // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker, /*isForAccess*/ true)); + symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker)); } else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } } } function addPropertySymbol(symbol) { + // For a computed property with an accessible name like `Symbol.iterator`, + // we'll add a completion for the *name* `Symbol` instead of for the property. // 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 === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; - return leftName && typeChecker.getSymbolAtLocation(leftName); - }); - if (symbolSymbol) { - symbols.push(symbolSymbol); - symbolToOriginInfoMap[ts.getSymbolId(symbolSymbol)] = { type: "symbol-member" }; + var computedPropertyName = ts.firstDefined(symbol.declarations, function (decl) { return ts.tryCast(ts.getNameOfDeclaration(decl), ts.isComputedPropertyName); }); + if (computedPropertyName) { + var leftMostName = getLeftMostName(computedPropertyName.expression); // The completion is for `Symbol`, not `iterator`. + var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); + // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. + var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); + if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + symbols.push(firstAccessibleSymbol); + symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = { type: "symbol-member" }; + } } else { symbols.push(symbol); @@ -91378,10 +92166,10 @@ 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 !== 274 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { - for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { + for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { type: "this-type" }; symbols.push(symbol); @@ -91414,10 +92202,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 274 /* SourceFile */: - case 202 /* TemplateExpression */: - case 265 /* JsxExpression */: - case 213 /* Block */: + case 277 /* SourceFile */: + case 204 /* TemplateExpression */: + case 268 /* JsxExpression */: + case 216 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -91464,12 +92252,12 @@ var ts; return parentKind === 152 /* PropertyDeclaration */ || parentKind === 151 /* PropertySignature */ || parentKind === 149 /* Parameter */ || - parentKind === 232 /* VariableDeclaration */ || + parentKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 237 /* TypeAliasDeclaration */; + return parentKind === 240 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 208 /* AsExpression */; + return parentKind === 210 /* AsExpression */; } } return false; @@ -91572,11 +92360,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; + if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; } } return false; @@ -91586,36 +92374,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 187 /* CallExpression */ // func( a, | + return containingNodeKind === 189 /* 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 === 190 /* NewExpression */ // new C(a, | + || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 187 /* CallExpression */ // func( | + return containingNodeKind === 189 /* 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 */ + || containingNodeKind === 190 /* NewExpression */ // new C(a| + || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + return containingNodeKind === 185 /* 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 === 239 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 200 /* BinaryExpression */; // x = a| + return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 202 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: @@ -91653,16 +92441,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = hasIndexSignature(typeForObject); - typeMembers = getPropertiesForCompletion(typeForObject, typeChecker, /*isForAccess*/ false); + typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -91673,7 +92461,7 @@ 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 === 222 /* ForOfStatement */; + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 225 /* ForOfStatement */; if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); @@ -91720,7 +92508,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -91764,8 +92552,8 @@ 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); // TODO: GH#18217 - return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); + var type = typeChecker.getTypeAtLocation(baseTypeNode); + return type && typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); } @@ -91835,14 +92623,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: - case 263 /* JsxAttributes */: - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { + case 187 /* PropertyAccessExpression */: + case 266 /* JsxAttributes */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 262 /* JsxAttribute */) { + else if (parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91854,7 +92642,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 === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91864,8 +92652,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 265 /* JsxExpression */ && - parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { + parent.kind === 268 /* JsxExpression */ && + parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91873,7 +92661,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91893,49 +92681,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 232 /* VariableDeclaration */ || - containingNodeKind === 233 /* VariableDeclarationList */ || - containingNodeKind === 214 /* VariableStatement */ || - containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 235 /* VariableDeclaration */ || + containingNodeKind === 236 /* VariableDeclarationList */ || + containingNodeKind === 217 /* VariableStatement */ || + containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 182 /* BindingElement */; // var {x :html| + return containingNodeKind === 184 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 269 /* CatchClause */ || + return containingNodeKind === 272 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | - containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | + containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| + (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 248 /* ImportSpecifier */ || - containingNodeKind === 252 /* ExportSpecifier */ || - containingNodeKind === 246 /* NamespaceImport */; + return containingNodeKind === 251 /* ImportSpecifier */ || + containingNodeKind === 255 /* ExportSpecifier */ || + containingNodeKind === 249 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -92019,9 +92807,9 @@ 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 !== 270 /* PropertyAssignment */ && - m.kind !== 271 /* ShorthandPropertyAssignment */ && - m.kind !== 182 /* BindingElement */ && + if (m.kind !== 273 /* PropertyAssignment */ && + m.kind !== 274 /* ShorthandPropertyAssignment */ && + m.kind !== 184 /* BindingElement */ && m.kind !== 154 /* MethodDeclaration */ && m.kind !== 156 /* GetAccessor */ && m.kind !== 157 /* SetAccessor */) { @@ -92043,7 +92831,7 @@ var ts; // NOTE: if one only performs this step when m.name is an identifier, // things like '__proto__' are not filtered out. var name = ts.getNameOfDeclaration(m); - existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; + existingName = name && ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } @@ -92102,7 +92890,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 262 /* JsxAttribute */) { + if (attr.kind === 265 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -92209,47 +92997,28 @@ var ts; } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { - var jsDoc = getJsDocHavingNode(node).jsDoc; - if (!jsDoc) - return undefined; - for (var _i = 0, jsDoc_1 = jsDoc; _i < jsDoc_1.length; _i++) { - var _a = jsDoc_1[_i], pos = _a.pos, end = _a.end, tags = _a.tags; - if (!tags || position < pos || position > end) - continue; - for (var i = tags.length - 1; i >= 0; i--) { - var tag = tags[i]; - if (position >= tag.pos) { - return tag; - } - } - } + var jsdoc = ts.findAncestor(node, ts.isJSDoc); + return jsdoc && jsdoc.tags && (ts.rangeContainsPosition(jsdoc, position) ? ts.findLast(jsdoc.tags, function (tag) { return tag.pos < position; }) : undefined); } - function getJsDocHavingNode(node) { - if (!ts.isToken(node)) - return node; - switch (node.kind) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - // if the current token is var, let or const, skip the VariableDeclarationList - return node.parent.parent; - default: - return node.parent; - } + function getPropertiesForObjectExpression(contextualType, obj, checker) { + return contextualType.isUnion() + ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { + // 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. + return !(memberType.flags & 32764 /* Primitive */ || + checker.isArrayLikeType(memberType) || + ts.typeHasCallOrConstructSignatures(memberType, checker) || + checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); + })) + : contextualType.getApparentProperties(); } /** * Gets all properties on a type, but if that type is a union of several types, * excludes array-like types or callable/constructable types. */ - function getPropertiesForCompletion(type, checker, isForAccess) { - if (!(type.isUnion())) { - return ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); - } - // 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 & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); - }); - return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); + function getPropertiesForCompletion(type, checker) { + return type.isUnion() + ? ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") + : ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } /** * Returns the immediate owning class declaration of a context token, @@ -92258,7 +93027,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 300 /* SyntaxList */: + case 303 /* 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); @@ -92305,7 +93074,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -92314,12 +93083,16 @@ var ts; return ts.Debug.assertNever(triggerCharacter); } } + function binaryExpressionMayBeOpenTag(_a) { + var left = _a.left; + return ts.nodeIsMissing(left); + } function isStringLiteralOrTemplate(node) { switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: return true; default: return false; @@ -92453,7 +93226,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -92485,16 +93258,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 227 /* SwitchStatement */: - if (statement.kind === 223 /* ContinueStatement */) { + case 230 /* SwitchStatement */: + if (statement.kind === 226 /* ContinueStatement */) { return false; } // falls through - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -92504,24 +93277,17 @@ var ts; }); } function getModifierOccurrences(modifier, declaration) { - var modifierFlag = ts.modifierToFlag(modifier); - return ts.mapDefined(getNodesToSearchForModifier(declaration, modifierFlag), function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - var mod = ts.find(node.modifiers, function (m) { return m.kind === modifier; }); - ts.Debug.assert(!!mod); - return mod; - } - }); + return ts.mapDefined(getNodesToSearchForModifier(declaration, ts.modifierToFlag(modifier)), function (node) { return ts.findModifier(node, modifier); }); } function getNodesToSearchForModifier(declaration, modifierFlag) { // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: - case 213 /* Block */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: + case 216 /* Block */: + case 269 /* CaseClause */: + case 270 /* 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]); @@ -92531,10 +93297,10 @@ var ts; } case 155 /* Constructor */: case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -92567,7 +93333,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 === 218 /* DoStatement */) { + if (loopNode.kind === 221 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -92587,13 +93353,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -92965,12 +93731,13 @@ var ts; if (!markSeenDirectImport(direct)) { continue; } - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -92983,20 +93750,20 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -93006,7 +93773,7 @@ var ts; directImports.push(direct); } break; - case 179 /* ImportType */: + case 181 /* ImportType */: directImports.push(direct); break; default: @@ -93023,7 +93790,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -93078,7 +93845,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 243 /* ImportEqualsDeclaration */) { + if (decl.kind === 246 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -93088,7 +93855,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 179 /* ImportType */) { + if (decl.kind === 181 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -93103,17 +93870,17 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 250 /* ExportDeclaration */) { + if (decl.kind === 253 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -93163,7 +93930,7 @@ var ts; } } else { - var localSymbol = element.kind === 252 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 255 /* 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); @@ -93192,7 +93959,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 === 274 /* SourceFile */) { + if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -93222,7 +93989,8 @@ var ts; var map = ts.createMap(); for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { var sourceFile = sourceFiles_6[_i]; - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { @@ -93239,7 +94007,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 === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -93254,15 +94022,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: { + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -93286,7 +94054,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 185 /* PropertyAccessExpression */) { + if (parent.kind === 187 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -93408,10 +94176,10 @@ var ts; // 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 === 232 /* VariableDeclaration */) { + if (parent.kind === 235 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -93420,15 +94188,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 248 /* ImportSpecifier */: + case 251 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -93461,21 +94229,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 274 /* SourceFile */) { + if (parent.kind === 277 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -93510,13 +94278,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* 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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var result_6 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_6.push(nodeEntry(node)); }); return result_6; @@ -93532,8 +94300,7 @@ var ts; return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true }); } } - function findReferencedEntries(program, cancellationToken, sourceFiles, sourceFile, position, options) { - var node = ts.getTouchingPropertyName(sourceFile, position); + function findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options) { return ts.map(flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options)), toReferenceEntry); } FindAllReferences.findReferencedEntries = findReferencedEntries; @@ -93620,13 +94387,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 205 /* ClassExpression */) { + else if (node.kind === 207 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -93739,10 +94506,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 274 /* SourceFile */: + case 277 /* 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -93900,7 +94667,7 @@ var ts; this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; - /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ + /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { if (searchOptions === void 0) { searchOptions = {}; } // Note: if this is an external module symbol, the name doesn't include quotes. @@ -93983,6 +94750,24 @@ var ts; } } } + function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { + var importTracker = FindAllReferences.createImportTracker(sourceFiles, ts.arrayToSet(sourceFiles, function (f) { return f.fileName; }), checker, cancellationToken); + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers; + for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { + var importLocation = importSearches_2[_i][0]; + cb(importLocation); + } + for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) { + var indirectUser = indirectUsers_2[_b]; + for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { + var node = _d[_c]; + if (ts.isIdentifier(node) && checker.getSymbolAtLocation(node) === exportSymbol) { + cb(node); + } + } + } + } + Core.eachExportReference = eachExportReference; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; @@ -94015,9 +94800,9 @@ var ts; : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 184 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 182 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -94039,7 +94824,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 === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -94049,7 +94834,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, 235 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -94078,7 +94863,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 277 /* 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; @@ -94117,6 +94902,28 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function eachSignatureCall(signature, sourceFiles, checker, cb) { + if (!signature.name || !ts.isIdentifier(signature.name)) + return; + var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { + var name = _b[_a]; + if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) + continue; + var called = ts.climbPastPropertyAccess(name); + var call = called.parent; + if (!ts.isCallExpression(call) || call.expression !== called) + continue; + var referenceSymbol = checker.getSymbolAtLocation(name); + if (referenceSymbol && checker.getRootSymbols(referenceSymbol).some(function (s) { return s === symbol; })) { + cb(call); + } + } + } + } + Core.eachSignatureCall = eachSignatureCall; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos); }); @@ -94341,6 +95148,7 @@ var ts; function getReferenceForShorthandProperty(_a, search, state) { var flags = _a.flags, valueDeclaration = _a.valueDeclaration; var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + var name = valueDeclaration && ts.getNameOfDeclaration(valueDeclaration); /* * Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment * has two meanings: property name and property value. Therefore when we do findAllReference at the position where @@ -94348,8 +95156,8 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && search.includes(shorthandValueSymbol)) { - addReference(ts.getNameOfDeclaration(valueDeclaration), shorthandValueSymbol, state); + if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { @@ -94457,7 +95265,7 @@ var ts; if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -94477,7 +95285,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 213 /* Block */) { + if (body.kind === 216 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -94505,13 +95313,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 183 /* ArrayLiteralExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 185 /* ArrayLiteralExpression */: return true; default: return false; @@ -94609,20 +95417,20 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -94630,19 +95438,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* 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 274 /* SourceFile */: - return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); + case 277 /* SourceFile */: + return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -94844,16 +95652,17 @@ var ts; }); } ts.getEditsForFileRename = getEditsForFileRename; + // exported for tests function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var canonicalPath = getCanonicalFileName(path); - if (canonicalPath === canonicalOldPath) + if (getCanonicalFileName(path) === canonicalOldPath) return newFileOrDirPath; - var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + var suffix = ts.tryRemoveDirectoryPrefix(path, canonicalOldPath, getCanonicalFileName); return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; }; } + ts.getPathUpdater = getPathUpdater; function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) @@ -94924,9 +95733,10 @@ var ts; } } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { - var _loop_15 = function (sourceFile) { - var newFromOld = oldToNew(sourceFile.fileName); - var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.fileName; + var allFiles = program.getSourceFiles(); + var _loop_14 = function (sourceFile) { + var newFromOld = oldToNew(sourceFile.path); + var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.path; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); var oldFromNew = newToOld(sourceFile.fileName); var oldImportFromPath = oldFromNew || sourceFile.fileName; @@ -94939,20 +95749,24 @@ var ts; var newAbsolute = oldToNew(oldAbsolute); return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); }, function (importLiteral) { + var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + // No need to update if it's an ambient module^M + if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. // TODO:GH#18217 ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) - : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); - // If neither the importing source file nor the imported file moved, do nothing. - return toImport === undefined || !toImport.updated && !importingSourceFileMoved - ? undefined - : ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, preferences); + : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew); + // Need an update if the imported file moved, or the importing file moved and was using a relative path. + return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text))) + ? ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, allFiles, preferences) + : undefined; }); }; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - _loop_15(sourceFile); + for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { + var sourceFile = allFiles_1[_i]; + _loop_14(sourceFile); } } function combineNormal(pathA, pathB) { @@ -94961,12 +95775,10 @@ var ts; 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; + function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) { + if (importedModuleSymbol) { + // `find` should succeed because we checked for ambient modules before calling this function. + var oldFileName = ts.find(importedModuleSymbol.declarations, ts.isSourceFile).fileName; var newFileName = oldToNew(oldFileName); return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true }; } @@ -95042,7 +95854,8 @@ var ts; return getDefinitionInfoForIndexSignatures(node, typeChecker); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); - if (calledDeclaration) { + // Don't go to the component constructor definition for a JSX element, just go to the component definition. + if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && ts.isConstructorDeclaration(calledDeclaration))) { var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. @@ -95062,7 +95875,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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -95111,7 +95924,7 @@ var ts; */ function symbolMatchesSignature(s, calledDeclaration) { return s === calledDeclaration.symbol || s === calledDeclaration.symbol.parent || - ts.isVariableDeclaration(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; + !ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; } function getReferenceAtPosition(sourceFile, position, program) { var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); @@ -95204,11 +96017,11 @@ var ts; return true; } switch (declaration.kind) { - case 245 /* ImportClause */: - case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: return true; - case 248 /* ImportSpecifier */: - return declaration.parent.kind === 247 /* NamedImports */; + case 251 /* ImportSpecifier */: + return declaration.parent.kind === 250 /* NamedImports */; default: return false; } @@ -95262,7 +96075,7 @@ var ts; return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); } function findReferenceInPosition(refs, pos) { - return ts.find(refs, function (ref) { return ref.pos <= pos && pos <= ref.end; }); + return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; function getDefinitionInfoForFileReference(name, targetFileName) { @@ -95367,11 +96180,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: return [declaration]; - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -95392,16 +96205,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return withNode(tag.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -95531,7 +96344,7 @@ var ts; if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { return undefined; } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; @@ -95549,10 +96362,7 @@ var ts; var singleLineResult = "/** */"; return { newText: singleLineResult, caretOffset: 3 }; } - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - 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 indentationStr = getIndentationStringAtPosition(sourceFile, position); // 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) @@ -95560,8 +96370,7 @@ var ts; // * TODO: other tags. // * the closing comment line // * if the caret was directly in front of the object, then we add an extra line and indentation. - var preamble = "/**" + newLine + - indentationStr + " * "; + var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + @@ -95569,6 +96378,14 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function getIndentationStringAtPosition(sourceFile, position) { + var text = sourceFile.text; + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + var pos = lineStart; + for (; pos <= position && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) + ; + return text.slice(lineStart, pos); + } function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; @@ -95580,20 +96397,21 @@ var ts; function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: case 151 /* PropertySignature */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 237 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 240 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -95601,14 +96419,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 274 /* SourceFile */: + case 277 /* SourceFile */: return undefined; - case 239 /* ModuleDeclaration */: + case 242 /* 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 === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 200 /* BinaryExpression */: { + return commentOwner.parent.kind === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 202 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -95628,14 +96446,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return rightHandSide.parameters; - case 205 /* ClassExpression */: { + case 207 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -95654,7 +96472,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_16 = function (sourceFile) { + var _loop_15 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { return "continue"; @@ -95664,15 +96482,12 @@ 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_16(sourceFile); + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_15(sourceFile); } rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - return rawItems.map(createNavigateToItem); + return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } NavigateTo.getNavigateToItems = getNavigateToItems; function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { @@ -95687,23 +96502,23 @@ var ts; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 + // If the pattern has dots in it, then also see if the declaration container matches as well. + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } } else { - // If the pattern has dots in it, then also see if the declaration container matches as well. rawItems.push({ name: name, fileName: fileName, matchKind: match.kind, isCaseSensitive: match.isCaseSensitive, declaration: declaration }); } } } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 245 /* ImportClause */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - var importer = checker.getSymbolAtLocation(declaration.name); + case 248 /* ImportClause */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; default: @@ -95748,14 +96563,14 @@ 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 === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; + if (name && name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + return ts.emptyArray; } // Now, walk up our containers, adding all their names to the container array. var container = ts.getContainerNode(declaration); while (container) { if (!tryAddSingleDeclarationName(container, containers)) { - return undefined; + return ts.emptyArray; } container = ts.getContainerNode(container); } @@ -95780,7 +96595,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 */ // TODO: GH#18217 Just use `container ? ...` + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -95941,19 +96756,19 @@ var ts; addLeafNode(node); } break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addLeafNode(importClause); + addLeafNode(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -95964,8 +96779,8 @@ var ts; } } break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -95986,12 +96801,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -96001,9 +96816,9 @@ var ts; } endNode(); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -96011,18 +96826,18 @@ var ts; } endNode(); break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 252 /* ExportSpecifier */: - case 243 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: case 160 /* IndexSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -96030,7 +96845,7 @@ var ts; case 3 /* PrototypeProperty */: case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); - break; + return; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: @@ -96106,7 +96921,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -96116,7 +96931,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -96146,7 +96961,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -96154,16 +96969,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -96173,16 +96988,16 @@ var ts; } } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -96220,25 +97035,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 274 /* SourceFile */: - case 237 /* TypeAliasDeclaration */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 277 /* SourceFile */: + case 240 /* TypeAliasDeclaration */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return true; case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -96248,8 +97063,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; @@ -96260,7 +97075,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; + return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; }); } } @@ -96317,7 +97132,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 === 239 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -96328,16 +97143,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 === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 + return decl.body.kind === 242 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -96347,16 +97162,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 === 232 /* VariableDeclaration */) { + else if (node.parent.kind === 235 /* 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 === 200 /* BinaryExpression */ && + else if (node.parent.kind === 202 /* 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 === 270 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 273 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -96369,9 +97184,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: return true; default: return false; @@ -96427,10 +97242,7 @@ var ts; }); // Delete or replace the first import. if (newImportDecls.length === 0) { - changeTracker.deleteNode(sourceFile, oldImportDecls[0], { - useNonAdjustedStartPosition: true, - useNonAdjustedEndPosition: false, - }); + changeTracker.delete(sourceFile, oldImportDecls[0]); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. @@ -96442,7 +97254,7 @@ var ts; } // Delete any subsequent imports. for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + changeTracker.delete(sourceFile, oldImportDecls[i]); } } } @@ -96738,7 +97550,7 @@ var ts; var currentLineStart = lineStarts[i]; var lineEnd = i + 1 === lineStarts.length ? sourceFile.getEnd() : lineStarts[i + 1] - 1; var lineText = sourceFile.text.substring(currentLineStart, lineEnd); - var result = lineText.match(/^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/); + var result = isRegionDelimiter(lineText); if (!result || ts.isInComment(sourceFile, currentLineStart)) { continue; } @@ -96756,6 +97568,10 @@ var ts; } } } + var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + function isRegionDelimiter(lineText) { + return regionDelimiterRegExp.exec(lineText); + } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); if (!comments) @@ -96763,11 +97579,19 @@ var ts; var firstSingleLineCommentStart = -1; var lastSingleLineCommentEnd = -1; var singleLineCommentCount = 0; - for (var _i = 0, comments_3 = comments; _i < comments_3.length; _i++) { - var _a = comments_3[_i], kind = _a.kind, pos = _a.pos, end = _a.end; + var sourceText = sourceFile.getFullText(); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var _a = comments_2[_i], kind = _a.kind, pos = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { case 2 /* SingleLineCommentTrivia */: + // never fold region delimiters into single-line comment regions + var commentText = sourceText.slice(pos, end); + if (isRegionDelimiter(commentText)) { + combineAndAddMultipleSingleLineComments(); + singleLineCommentCount = 0; + break; + } // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (singleLineCommentCount === 0) { @@ -96798,24 +97622,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* 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 218 /* DoStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 269 /* CatchClause */: + case 221 /* DoStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 272 /* CatchClause */: return spanForNode(n.parent); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -96830,16 +97654,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanForNode(n.parent); - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 241 /* CaseBlock */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 244 /* CaseBlock */: return spanForNode(n); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -96913,7 +97737,6 @@ var ts; if (!candidateMatch) { return undefined; } - candidateContainers = candidateContainers || []; // -1 because the last part was checked against the name, and only the rest // of the parts are checked against the container. if (dotSeparatedSegments.length - 1 > candidateContainers.length) { @@ -97150,13 +97973,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_17 = 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_17(start); + var state_4 = _loop_16(start); if (typeof state_4 === "object") return state_4.value; } @@ -97672,21 +98495,12 @@ var ts; (function (ts) { var Rename; (function (Rename) { - function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); + function getRenameInfo(program, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }) : undefined; return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); - function isDefinedInLibraryFile(declaration) { - if (!defaultLibFileName) { - return false; - } - var sourceFile = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - return canonicalName === getCanonicalDefaultLibName(); - } } Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { @@ -97780,7 +98594,7 @@ var ts; InvocationKind[InvocationKind["Call"] = 0] = "Call"; InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; })(InvocationKind || (InvocationKind = {})); - function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { + function getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -97788,6 +98602,12 @@ var ts; // We are at the beginning of the file return undefined; } + if (shouldCarefullyCheckContext(triggerReason)) { + // In the middle of a string, don't provide signature help unless the user explicitly requested it. + if (ts.isInString(sourceFile, position, startingToken)) { + return undefined; + } + } var argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); if (!argumentInfo) return undefined; @@ -97806,6 +98626,10 @@ var ts; return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + function shouldCarefullyCheckContext(reason) { + // Only need to be careful if the user typed a character and signature help wasn't showing. + return !!reason && reason.kind === "characterTyped"; + } function getCandidateInfo(argumentInfo, checker) { var invocation = argumentInfo.invocation; if (invocation.kind === 0 /* Call */) { @@ -97828,11 +98652,11 @@ var ts; return undefined; } var typeChecker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_17 = function (sourceFile) { var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - var _loop_19 = function (declaration) { + var _loop_18 = function (declaration) { var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -97846,7 +98670,7 @@ var ts; }; for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { var declaration = declarations_13[_i]; - var state_6 = _loop_19(declaration); + var state_6 = _loop_18(declaration); if (typeof state_6 === "object") return state_6; } @@ -97854,7 +98678,7 @@ var ts; }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - var state_5 = _loop_18(sourceFile); + var state_5 = _loop_17(sourceFile); if (typeof state_5 === "object") return state_5.value; } @@ -97923,10 +98747,10 @@ var ts; return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -98075,7 +98899,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -98084,7 +98908,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - var _loop_20 = function (n) { + 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. ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); }); @@ -98094,7 +98918,7 @@ var ts; } }; for (var n = node; !ts.isBlock(n) && !ts.isSourceFile(n); n = n.parent) { - var state_7 = _loop_20(n); + var state_7 = _loop_19(n); if (typeof state_7 === "object") return state_7.value; } @@ -98239,7 +99063,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var decl = ts.getDeclarationOfJSInitializer(node); if (decl) { var symbol_3 = decl.symbol; @@ -98249,7 +99073,7 @@ var ts; } } // falls through if no diagnostic was created - case 234 /* FunctionDeclaration */: + case 237 /* 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)); @@ -98279,11 +99103,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); // TODO: GH#18217 - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -98300,12 +99124,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -98328,7 +99152,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -98373,7 +99197,7 @@ var ts; if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return "parameter" /* parameterElement */; } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { return "const" /* constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { @@ -98416,11 +99240,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 257 /* JsxOpeningElement */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -98460,7 +99284,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 185 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 187 /* 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)) { @@ -98481,7 +99305,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 190 /* 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 @@ -98568,7 +99392,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 207 /* 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 @@ -98602,7 +99426,7 @@ var ts; } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } @@ -98612,7 +99436,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -98650,7 +99474,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 237 /* TypeAliasDeclaration */) { + else if (declaration.kind === 240 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -98667,7 +99491,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 273 /* EnumMember */) { + if (declaration.kind === 276 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -98697,17 +99521,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 249 /* ExportAssignment */: + case 252 /* 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 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -98716,7 +99540,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 243 /* ImportEqualsDeclaration */) { + if (declaration.kind === 246 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -98794,10 +99618,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 === 274 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -98909,16 +99733,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 192 /* FunctionExpression */) { + if (declaration.kind === 194 /* FunctionExpression */) { return true; } - if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* FunctionDeclaration */) { + if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* 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 === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { + if (parent.kind === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { return false; } } @@ -99031,7 +99855,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_21 = function (opt) { + var _loop_20 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -99050,7 +99874,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_21(opt); + _loop_20(opt); } return options; } @@ -99227,10 +100051,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 262 /* JsxAttribute */: - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 265 /* JsxAttribute */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* 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 */; } @@ -99711,44 +100535,44 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 220 /* ForStatement */; + return context.contextNode.kind === 223 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 171 /* ConditionalType */: - case 208 /* AsExpression */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 173 /* ConditionalType */: + case 210 /* AsExpression */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 161 /* TypePredicate */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 182 /* BindingElement */: + case 184 /* BindingElement */: // equals in type X = ... - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: // equal in p = 0; case 149 /* Parameter */: - case 273 /* EnumMember */: + case 276 /* 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 221 /* ForInStatement */: + case 224 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] 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 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; @@ -99764,19 +100588,19 @@ var ts; return contextKind === 152 /* PropertyDeclaration */ || contextKind === 151 /* PropertySignature */ || contextKind === 149 /* Parameter */ || - contextKind === 232 /* VariableDeclaration */ || + contextKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 201 /* ConditionalExpression */ || - context.contextNode.kind === 171 /* ConditionalType */; + return context.contextNode.kind === 203 /* ConditionalExpression */ || + context.contextNode.kind === 173 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 180 /* ObjectBindingPattern */ || - context.contextNode.kind === 177 /* MappedType */ || + return context.contextNode.kind === 182 /* ObjectBindingPattern */ || + context.contextNode.kind === 179 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -99802,17 +100626,17 @@ var ts; return true; } switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 184 /* ObjectLiteralExpression */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 186 /* ObjectLiteralExpression */: + case 243 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -99820,13 +100644,13 @@ var ts; case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: case 158 /* CallSignature */: - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: case 155 /* Constructor */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -99835,40 +100659,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; + return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: case 166 /* TypeLiteral */: - case 239 /* ModuleDeclaration */: - case 250 /* ExportDeclaration */: - case 251 /* NamedExports */: - case 244 /* ImportDeclaration */: - case 247 /* NamedImports */: + case 242 /* ModuleDeclaration */: + case 253 /* ExportDeclaration */: + case 254 /* NamedExports */: + case 247 /* ImportDeclaration */: + case 250 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 269 /* CatchClause */: - case 240 /* ModuleBlock */: - case 227 /* SwitchStatement */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 272 /* CatchClause */: + case 243 /* ModuleBlock */: + case 230 /* SwitchStatement */: return true; - case 213 /* Block */: { + case 216 /* 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 !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { return true; } } @@ -99877,31 +100701,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - 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 */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 229 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 269 /* CatchClause */: + case 272 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 184 /* ObjectLiteralExpression */; + return context.contextNode.kind === 186 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 187 /* CallExpression */; + return context.contextNode.kind === 189 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 188 /* NewExpression */; + return context.contextNode.kind === 190 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -99913,28 +100737,28 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 193 /* ArrowFunction */; + return context.contextNode.kind === 195 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 179 /* ImportType */; + return context.contextNode.kind === 181 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; + return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; + return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 262 /* JsxAttribute */; + return context.nextTokenParent.kind === 265 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 262 /* JsxAttribute */; + return context.contextNode.kind === 265 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 256 /* JsxSelfClosingElement */; + return context.contextNode.kind === 259 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -99952,14 +100776,14 @@ var ts; return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 239 /* ModuleDeclaration */; + return context.contextNode.kind === 242 /* ModuleDeclaration */; } function isObjectTypeContext(context) { return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -99973,21 +100797,21 @@ var ts; } switch (parent.kind) { 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 192 /* TypeAssertionExpression */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -99998,16 +100822,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 190 /* TypeAssertionExpression */; + return context.contextNode.kind === 192 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 209 /* NonNullExpression */; + return context.contextNode.kind === 211 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -100241,17 +101065,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 274 /* SourceFile */: - case 213 /* Block */: - case 240 /* ModuleBlock */: + return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 277 /* SourceFile */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -100474,10 +101298,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - 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 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; case 156 /* GetAccessor */: return 125 /* GetKeyword */; case 157 /* SetAccessor */: return 136 /* SetKeyword */; case 154 /* MethodDeclaration */: @@ -100487,7 +101311,10 @@ var ts; // falls through case 152 /* PropertyDeclaration */: case 149 /* Parameter */: - return ts.getNameOfDeclaration(node).kind; + var name = ts.getNameOfDeclaration(node); + if (name) { + return name.kind; + } } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { @@ -100531,15 +101358,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 177 /* MappedType */) { + if (container.kind !== 179 /* MappedType */) { return false; } break; @@ -100639,7 +101466,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -101007,56 +101834,47 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword + tokenAtPosition) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } + var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); + if (jsdoc) + tokenAtPosition = jsdoc.parent; var tokenStart = tokenAtPosition.getStart(sourceFile); if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } - if (precedingToken === undefined) { - precedingToken = ts.findPrecedingToken(position, sourceFile); - } + precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); - var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? - trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : - trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; - if (commentRanges) { - for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { - var range = commentRanges_1[_i]; - // The end marker of a single-line comment does not include the newline character. - // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for closed multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // However, unterminated multi-line comments *do* contain their end. - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - // - if ((range.pos < position && position < range.end || - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()))) { - return (range.kind === 3 /* MultiLineCommentTrivia */ || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; - } - } - } - return undefined; + var commentRanges = ts.concatenate(trailingRangesOfPreviousToken, leadingCommentRangesOfNextToken); + return commentRanges && ts.find(commentRanges, function (range) { return ts.rangeContainsPositionExclusive(range, position) || + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -101064,8 +101882,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -101170,9 +101988,9 @@ var ts; if (options.indentStyle === ts.IndentStyle.None) { return 0; } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword - if (enclosingCommentRange) { + var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -101190,7 +102008,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* 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 */) { @@ -101346,7 +102164,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 === 274 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -101394,7 +102212,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -101412,13 +102230,13 @@ var ts; switch (node.parent.kind) { case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.parent.properties; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return node.parent.elements; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: @@ -101429,21 +102247,21 @@ var ts; return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 188 /* NewExpression */: - case 187 /* CallExpression */: { + case 190 /* NewExpression */: + case 189 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -101483,10 +102301,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: node = node.expression; break; default: @@ -101551,82 +102369,82 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - 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 219 /* ExpressionStatement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 185 /* ArrayLiteralExpression */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 177 /* MappedType */: + case 179 /* 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 244 /* CaseBlock */: + case 270 /* DefaultClause */: + case 269 /* CaseClause */: + case 193 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 217 /* VariableStatement */: + case 252 /* ExportAssignment */: + case 228 /* ReturnStatement */: + case 203 /* ConditionalExpression */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: + case 259 /* JsxSelfClosingElement */: + case 268 /* 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 175 /* ParenthesizedType */: + case 191 /* TaggedTemplateExpression */: + case 199 /* AwaitExpression */: + case 254 /* NamedExports */: + case 250 /* NamedImports */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 152 /* PropertyDeclaration */: return true; - case 232 /* VariableDeclaration */: - case 270 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 235 /* VariableDeclaration */: + case 273 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } 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 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: - case 193 /* ArrowFunction */: + case 195 /* 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 */: + return childKind !== 216 /* Block */; + case 253 /* ExportDeclaration */: + return childKind !== 254 /* NamedExports */; + case 247 /* ImportDeclaration */: + return childKind !== 248 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); + case 258 /* JsxElement */: + return childKind !== 261 /* JsxClosingElement */; + case 262 /* JsxFragment */: + return childKind !== 264 /* JsxClosingFragment */; + case 172 /* IntersectionType */: + case 171 /* UnionType */: if (childKind === 166 /* TypeLiteral */) { return false; } @@ -101638,17 +102456,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: { - if (parent.kind !== 213 /* Block */) { + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: { + if (parent.kind !== 216 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 194 /* FunctionExpression */ || grandParent.kind === 237 /* FunctionDeclaration */); } - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return true; default: return false; @@ -101777,7 +102595,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 === 184 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -101793,8 +102611,8 @@ var ts; this.formatContext = formatContext; this.changes = []; this.newFiles = []; - this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map + this.deletedNodes = []; } ChangeTracker.fromContext = function (context) { return new ChangeTracker(ts.getNewLineOrDefaultFromHost(context.host, context.formatContext.options), context.formatContext); @@ -101808,13 +102626,11 @@ var ts; this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); return this; }; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { - if (options === void 0) { options = {}; } - var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); - var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); - return this; + ChangeTracker.prototype.delete = function (sourceFile, node) { + this.deletedNodes.push({ sourceFile: sourceFile, node: node, }); + }; + ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { + this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } @@ -101829,30 +102645,6 @@ var ts; 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) { - ts.Debug.fail("node is not a list element"); - return this; - } - var index = ts.indexOfNode(containingList, node); - if (index < 0) { - return this; - } - if (containingList.length === 1) { - this.deleteNode(sourceFile, node); - return this; - } - // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. - // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. - ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice"); - this.deletedNodesInLists.add(node); - this.deleteRange(sourceFile, { - pos: startPositionToDeleteNodeInList(sourceFile, node), - end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), - }); - return this; - }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); @@ -101918,7 +102710,7 @@ var ts; // If so, we do not want to separate the node from its comment if we can. // Otherwise, add an extra new line immediately before the error span. var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); - var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); @@ -101942,7 +102734,7 @@ var ts; } } else { - endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -101961,6 +102753,9 @@ var ts; else if (ts.isParameter(before)) { return {}; } + else if (ts.isStringLiteral(before) && ts.isImportDeclaration(before.parent) || ts.isNamedImports(before)) { + return { suffix: ", " }; + } return ts.Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { @@ -102020,6 +102815,9 @@ var ts; var endPosition = this.insertNodeAfterWorker(sourceFile, after, newNode); this.insertNodeAt(sourceFile, endPosition, newNode, this.getInsertNodeAfterOptions(sourceFile, after)); }; + ChangeTracker.prototype.insertNodeAtEndOfList = function (sourceFile, list, newNode) { + this.insertNodeAt(sourceFile, list.end, newNode, { prefix: ", " }); + }; ChangeTracker.prototype.insertNodesAfter = function (sourceFile, after, newNodes) { var endPosition = this.insertNodeAfterWorker(sourceFile, after, ts.first(newNodes)); this.insertNodesAt(sourceFile, endPosition, newNodes, this.getInsertNodeAfterOptions(sourceFile, after)); @@ -102040,32 +102838,34 @@ var ts; return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { - if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) { - return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + switch (node.kind) { + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + case 235 /* VariableDeclaration */: + case 9 /* StringLiteral */: + case 71 /* Identifier */: + return { prefix: ", " }; + case 273 /* PropertyAssignment */: + return { suffix: "," + this.newLineCharacter }; + case 84 /* ExportKeyword */: + return { prefix: " " }; + case 149 /* Parameter */: + return {}; + default: + ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it + return { suffix: this.newLineCharacter }; } - else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { - return { suffix: this.newLineCharacter }; - } - else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { - return { prefix: ", " }; - } - else if (ts.isPropertyAssignment(node)) { - return { suffix: "," + this.newLineCharacter }; - } - else if (ts.isParameter(node)) { - return {}; - } - return ts.Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 193 /* ArrowFunction */) { + if (node.kind === 195 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); - this.deleteNode(sourceFile, arrow); + deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` @@ -102073,14 +102873,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 !== 213 /* Block */) { + if (node.body.kind !== 216 /* 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 === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -102106,7 +102906,7 @@ var ts; if (index !== containingList.length - 1) { // any element except the last one // use next sibling as an anchor - var nextToken = ts.getTokenAtPosition(sourceFile, after.end, /*includeJsDocComment*/ false); + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); if (nextToken && isSeparator(after, nextToken)) { // for list // a, b, c @@ -102211,14 +103011,25 @@ var ts; } }); }; - ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () { + ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - this.deletedNodesInLists.forEach(function (node) { + var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var _loop_21 = function (sourceFile, node) { + if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { + deleteDeclaration.deleteDeclaration(this_1, deletedNodesInLists, sourceFile, node); + } + }; + var this_1 = this; + for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { + var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; + _loop_21(sourceFile, node); + } + deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (node !== ts.last(list)) return; - var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2); + var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !deletedNodesInLists.has(n); }, list.length - 2); if (lastNonDeletedIndex !== -1) { _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) }); } @@ -102231,8 +103042,8 @@ var ts; * so we can only call this once and can't get the non-formatted text separately. */ ChangeTracker.prototype.getChanges = function (validate) { + this.finishDeleteDeclarations(); this.finishClassesWithNodesInsertedAtStart(); - this.finishTrailingCommaAfterDeletingNodesInList(); 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; @@ -102329,8 +103140,8 @@ var ts; })(changesToText || (changesToText = {})); function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { - var change = changes[i]; - text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + var _a = changes[i], span = _a.span, newText = _a.newText; + text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); } return text; } @@ -102532,6 +103343,177 @@ var ts; 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 `[` } + var deleteDeclaration; + (function (deleteDeclaration_1) { + function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { + switch (node.kind) { + case 149 /* Parameter */: { + var oldFunction = node.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, // 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. + ts.suppressLeadingAndTrailingTrivia(newFunction); + changes.replaceNode(sourceFile, oldFunction, newFunction); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 247 /* ImportDeclaration */: + deleteNode(changes, sourceFile, node, + // For first import, leave header comment in place + node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); + break; + case 184 /* BindingElement */: + var pattern = node.parent; + var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + if (preserveComma) { + deleteNode(changes, sourceFile, node); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 235 /* VariableDeclaration */: + deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); + break; + case 148 /* TypeParameter */: { + var typeParameters = ts.getEffectiveTypeParameterDeclarations(node.parent); + if (typeParameters.length === 1) { + var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; + var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1); + var nextToken = ts.getTokenAtPosition(sourceFile, end); + ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); + ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); + changes.deleteNodeRange(sourceFile, previousToken, nextToken); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 251 /* ImportSpecifier */: + var namedImports = node.parent; + if (namedImports.elements.length === 1) { + deleteImportBinding(changes, sourceFile, namedImports); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 249 /* NamespaceImport */: + deleteImportBinding(changes, sourceFile, node); + break; + default: + if (ts.isImportClause(node.parent) && node.parent.name === node) { + deleteDefaultImport(changes, sourceFile, node.parent); + } + else if (ts.isCallLikeExpression(node.parent)) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + else { + deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + } + } + } + deleteDeclaration_1.deleteDeclaration = deleteDeclaration; + function deleteDefaultImport(changes, sourceFile, importClause) { + if (!importClause.namedBindings) { + // Delete the whole import + deleteNode(changes, sourceFile, importClause.parent); + } + else { + // import |d,| * as ns from './file' + var start = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26 /* CommaToken */) { + // shift first non-whitespace position after comma to the start position of the node + var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); + changes.deleteRange(sourceFile, { pos: start, end: end }); + } + else { + deleteNode(changes, sourceFile, importClause.name); + } + } + } + function deleteImportBinding(changes, sourceFile, node) { + if (node.parent.name) { + // Delete named imports while preserving the default import + // import d|, * as ns| from './file' + // import d|, { a }| from './file' + var previousToken = ts.Debug.assertDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1)); + changes.deleteRange(sourceFile, { pos: previousToken.getStart(sourceFile), end: node.end }); + } + else { + // Delete the entire import declaration + // |import * as ns from './file'| + // |import { a } from './file'| + var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + deleteNode(changes, sourceFile, importDecl); + } + } + function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { + var parent = node.parent; + if (parent.kind === 272 /* CatchClause */) { + // TODO: There's currently no unused diagnostic for this, could be a suggestion + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + return; + } + if (parent.declarations.length !== 1) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + return; + } + var gp = parent.parent; + switch (gp.kind) { + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: + changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); + break; + case 223 /* ForStatement */: + deleteNode(changes, sourceFile, parent); + break; + case 217 /* VariableStatement */: + deleteNode(changes, sourceFile, gp); + break; + default: + ts.Debug.assertNever(gp); + } + } + })(deleteDeclaration || (deleteDeclaration = {})); + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + // Exported for tests only! (TODO: improve tests to not need this) + function deleteNode(changes, sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + changes.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + textChanges_3.deleteNode = deleteNode; + function deleteNodeInList(changes, deletedNodesInLists, sourceFile, node) { + var containingList = ts.Debug.assertDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile)); + var index = ts.indexOfNode(containingList, node); + ts.Debug.assert(index !== -1); + if (containingList.length === 1) { + deleteNode(changes, sourceFile, node); + return; + } + // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. + // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. + ts.Debug.assert(!deletedNodesInLists.has(node), "Deleting a node twice"); + deletedNodesInLists.add(node); + changes.deleteRange(sourceFile, { + pos: startPositionToDeleteNodeInList(sourceFile, node), + end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), + }); + } })(textChanges = ts.textChanges || (ts.textChanges = {})); })(ts || (ts = {})); /* @internal */ @@ -102587,15 +103569,14 @@ var ts; function createCombinedCodeActions(changes, commands) { return { changes: changes, commands: commands }; } + codefix.createCombinedCodeActions = createCombinedCodeActions; function createFileTextChanges(fileName, textChanges) { return { fileName: fileName, textChanges: textChanges }; } codefix.createFileTextChanges = createFileTextChanges; function codeFixAll(context, errorCodes, use) { var commands = []; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { - return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); - }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); }); return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } codefix.codeFixAll = codeFixAll; @@ -102608,6 +103589,7 @@ var ts; } } } + codefix.eachDiagnostic = eachDiagnostic; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -102658,7 +103640,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, }); function makeChange(changeTracker, sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var decorator = ts.findAncestor(token, ts.isDecorator); ts.Debug.assert(!!decorator, "Expected position to be owned by a decorator."); var replacement = ts.createCall(decorator.expression, /*typeArguments*/ undefined, /*argumentsArray*/ undefined); @@ -102690,7 +103672,7 @@ var ts; }); }, }); function getDeclaration(file, pos) { - var name = ts.getTokenAtPosition(file, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(file, pos); // For an arrow function with no name, 'name' lands on the first parameter. return ts.tryCast(ts.isParameter(name.parent) ? name.parent.parent : name.parent, parameterShouldGetTypeFromJSDoc); } @@ -102737,24 +103719,24 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 232 /* VariableDeclaration */ || + node.kind === 235 /* VariableDeclaration */ || node.kind === 151 /* PropertySignature */ || node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 162 /* TypeReference */: return transformJSDocTypeReference(node); @@ -102778,7 +103760,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 288 /* 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); @@ -102844,8 +103826,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, err) { return doChange(changes, err.file, err.start, context.program.getTypeChecker()); }); }, }); function doChange(changes, sourceFile, position, checker) { - var deletedNodes = []; - var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false)); + var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; @@ -102854,20 +103835,20 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); + changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { ts.copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 - deleteNode(precedingNode); + changes.delete(sourceFile, precedingNode); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + changes.delete(sourceFile, ctorDeclaration); } break; } @@ -102877,22 +103858,6 @@ var ts; ts.copyComments(ctorDeclaration, newClassDeclaration, sourceFile); // Because the preceding node could be touched, we need to insert nodes before delete nodes. changes.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration); - for (var _i = 0, deletedNodes_1 = deletedNodes; _i < deletedNodes_1.length; _i++) { - var _a = deletedNodes_1[_i], node = _a.node, inList = _a.inList; - if (inList) { - changes.deleteNodeInList(sourceFile, node); - } - else { - changes.deleteNode(sourceFile, node); - } - } - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - // If parent node has already been deleted, do nothing - if (!deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n.node); })) { - deletedNodes.push({ node: node, inList: inList }); - } - } function createClassElementsFromSymbol(symbol) { var memberElements = []; // all instance members are stored in the "member" array of symbol @@ -102930,15 +103895,15 @@ 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 === 216 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 219 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); + changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 192 /* FunctionExpression */: { + case 194 /* 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, @@ -102946,12 +103911,12 @@ var ts; ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 193 /* ArrowFunction */: { + case 195 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 213 /* Block */) { + if (arrowFunctionBody.kind === 216 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -102979,7 +103944,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { @@ -103043,10 +104008,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -103099,20 +104064,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 187 /* CallExpression */: { + case 189 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -103154,8 +104119,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: { + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -103178,7 +104143,7 @@ var ts; if (ts.isExportsOrModuleExportsOrAlias(sourceFile, left)) { if (ts.isExportsOrModuleExportsOrAlias(sourceFile, right)) { // `const alias = module.exports;` or `module.exports = alias;` can be removed. - changes.deleteNode(sourceFile, assignment.parent); + changes.delete(sourceFile, assignment.parent); } else { var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right) @@ -103209,10 +104174,10 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 271 /* ShorthandPropertyAssignment */: - case 272 /* SpreadAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 275 /* SpreadAssignment */: return undefined; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); @@ -103269,7 +104234,7 @@ var ts; changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); if (semi) - changes.deleteNode(sourceFile, semi, { useNonAdjustedEndPosition: true }); + changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` @@ -103280,7 +104245,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -103288,10 +104253,10 @@ var ts; } } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -103309,7 +104274,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: { + case 182 /* 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 @@ -103320,7 +104285,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 181 /* ArrayBindingPattern */: { + case 183 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -103403,11 +104368,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node; - case 182 /* BindingElement */: + case 184 /* BindingElement */: return parent.propertyName !== node; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -103466,7 +104431,7 @@ var ts; }); }, }); function getQualifiedName(sourceFile, pos) { - var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ true), ts.isQualifiedName); + var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), ts.isQualifiedName); ts.Debug.assert(!!qualifiedName, "Expected position to be owned by a qualified name."); return ts.isIdentifier(qualifiedName.left) ? qualifiedName : undefined; } @@ -103511,7 +104476,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -103539,7 +104504,7 @@ var ts; } } function getHeritageClauseSymbolTable(classDeclaration, checker) { - var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var heritageClauseNode = ts.getEffectiveBaseTypeNode(classDeclaration); if (!heritageClauseNode) return ts.createSymbolTable(); var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); @@ -103553,42 +104518,109 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var ChangeTracker = ts.textChanges.ChangeTracker; + codefix.importFixId = "fixMissingImport"; + var errorCodes = [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, + ts.Diagnostics.Cannot_find_namespace_0.code, + 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, + ]; codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics.Cannot_find_name_0.code, - ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, - ts.Diagnostics.Cannot_find_namespace_0.code, - 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: 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, + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span; + var info = getFixesInfo(context, errorCode, span.start); + if (!info) + return undefined; + var fixes = info.fixes, symbolName = info.symbolName; + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference); }); + }, + fixIds: [codefix.importFixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, preferences = context.preferences; + // Namespace fixes don't conflict, so just build a list. + var addToNamespace = []; + // Keys are import clause node IDs. + var addToExisting = ts.createMap(); + // Keys are module specifiers. + var newImports = ts.createMap(); + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getFixesInfo(context, diag.code, diag.start); + if (!info || !info.fixes.length) + return; + var fixes = info.fixes, symbolName = info.symbolName; + var fix = ts.first(fixes); + switch (fix.kind) { + case 0 /* UseNamespace */: + addToNamespace.push(fix); + break; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + var key = String(ts.getNodeId(importClause)); + var entry = addToExisting.get(key); + if (!entry) { + addToExisting.set(key, entry = { importClause: importClause, defaultImport: undefined, namedImports: [] }); + } + if (importKind === 0 /* Named */) { + ts.pushIfUnique(entry.namedImports, symbolName); + } + else { + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + } + break; + } + case 2 /* AddNew */: { + var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind; + var entry = newImports.get(moduleSpecifier); + if (!entry) { + newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined }); + } + switch (importKind) { + case 1 /* Default */: + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + break; + case 0 /* Named */: + ts.pushIfUnique(entry.namedImports, symbolName); + break; + case 3 /* Equals */: + case 2 /* Namespace */: + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; + break; + } + break; + } + default: + ts.Debug.assertNever(fix); + } + }); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) { + var fix = addToNamespace_1[_i]; + addNamespaceQualifier(changes, sourceFile, fix); + } + addToExisting.forEach(function (_a) { + var importClause = _a.importClause, defaultImport = _a.defaultImport, namedImports = _a.namedImports; + doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports); + }); + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + newImports.forEach(function (imports, moduleSpecifier) { + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports); + }); + })); + }, }); - function createCodeAction(descriptionDiagnostic, diagnosticArgs, changes) { - // TODO: GH#20315 - return codefix.createCodeFixActionNoFixId("import", changes, [descriptionDiagnostic].concat(diagnosticArgs)); - } - function convertToImportCodeFixContext(context, symbolToken, symbolName) { - var program = context.program; - var checker = program.getTypeChecker(); - return { - host: context.host, - formatContext: context.formatContext, - sourceFile: context.sourceFile, - program: program, - checker: checker, - compilerOptions: program.getCompilerOptions(), - getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), - symbolName: symbolName, - symbolToken: symbolToken, - preferences: context.preferences, - }; - } + // Sorted with the preferred fix coming first. + var ImportFixKind; + (function (ImportFixKind) { + ImportFixKind[ImportFixKind["UseNamespace"] = 0] = "UseNamespace"; + ImportFixKind[ImportFixKind["AddToExisting"] = 1] = "AddToExisting"; + ImportFixKind[ImportFixKind["AddNew"] = 2] = "AddNew"; + })(ImportFixKind || (ImportFixKind = {})); var ImportKind; (function (ImportKind) { ImportKind[ImportKind["Named"] = 0] = "Named"; @@ -103596,13 +104628,13 @@ var ts; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; })(ImportKind || (ImportKind = {})); - function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, symbolToken, preferences) { + function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, allSourceFiles, formatContext, symbolToken, preferences) { var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, checker, allSourceFiles); ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, exportInfos, host, preferences)).moduleSpecifier; - var ctx = { host: host, program: program, checker: checker, compilerOptions: compilerOptions, sourceFile: sourceFile, formatContext: formatContext, symbolName: symbolName, getCanonicalFileName: getCanonicalFileName, symbolToken: symbolToken, preferences: preferences }; - return { moduleSpecifier: moduleSpecifier, codeAction: ts.first(getCodeActionsForImport(exportInfos, ctx)) }; + var fix = ts.first(getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences)); + return { moduleSpecifier: moduleSpecifier, codeAction: codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences)) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, checker, allSourceFiles) { @@ -103622,23 +104654,16 @@ var ts; }); return result; } - function getCodeActionsForImport(exportInfos, context) { - var result = []; - getCodeActionsForImport_separateExistingAndNew(exportInfos, context, result, result); - return result; + function getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences) { + var checker = program.getTypeChecker(); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var useNamespace = tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker); + var addToExisting = tryAddToExistingImport(existingImports); + // Don't bother providing an action to add a new import if we can add to an existing one. + var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); + return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); } - function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - 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) { + function tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -103655,29 +104680,31 @@ var ts; 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); + var moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { + return { kind: 0 /* UseNamespace */, namespacePrefix: namespace.text, symbolToken: symbolToken }; } } }); } - function tryAddToExistingImport(existingImports, context) { + function tryAddToExistingImport(existingImports) { 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); - } - } + if (declaration.kind !== 247 /* ImportDeclaration */) + return undefined; + var importClause = declaration.importClause; + if (!importClause) + return undefined; + var name = importClause.name, namedBindings = importClause.namedBindings; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + ? { kind: 1 /* AddToExisting */, importClause: importClause, importKind: importKind } + : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 244 /* ImportDeclaration */) { + if (declaration.kind === 247 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -103688,141 +104715,61 @@ var ts; var imports = _b.imports; return ts.mapDefined(imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } - function getCodeActionForNewImport(context, _a) { - var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; - var sourceFile = context.sourceFile, symbolName = context.symbolName, preferences = context.preferences; - var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); - var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifierWithoutQuotes, ts.getQuotePreference(sourceFile, preferences)); - var importDecl = importKind !== 3 /* Equals */ - ? ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClauseOfKind(importKind, symbolName), quotedModuleSpecifier) - : ts.createImportEqualsDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createIdentifier(symbolName), ts.createExternalModuleReference(quotedModuleSpecifier)); - var changes = ChangeTracker.with(context, function (t) { return ts.insertImport(t, sourceFile, importDecl); }); - // 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 separating code and import statements. - return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); - } - function createImportClauseOfKind(kind, symbolName) { - var id = ts.createIdentifier(symbolName); - switch (kind) { - case 1 /* Default */: - return ts.createImportClause(id, /*namedBindings*/ undefined); - case 2 /* Namespace */: - return ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(id)); - case 0 /* Named */: - return ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, id)])); - default: - ts.Debug.assertNever(kind); - } - } function getNewImportInfos(program, sourceFile, moduleSymbols, host, preferences) { var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var modulePathsGroups = ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences); - return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); + return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ kind: 2 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); }); // 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, addNew) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); - var newImportInfos = existingDeclaration - ? [existingDeclaration] - : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.host, ctx.preferences); - for (var _i = 0, newImportInfos_1 = newImportInfos; _i < newImportInfos_1.length; _i++) { - var info = newImportInfos_1[_i]; - addNew.push(getCodeActionForNewImport(ctx, info)); - } + return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 244 /* ImportDeclaration */ + var expression = declaration.kind === 247 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; - return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; + return expression && ts.isStringLiteral(expression) ? { kind: 2 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; } - function tryUpdateExistingImport(context, importClause, importKind) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - var name = importClause.name; - var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 - switch (importKind) { - case 1 /* Default */: - return name ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(ts.createIdentifier(symbolName), namedBindings)); - }); - case 0 /* Named */: { - var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - 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 === 247 /* NamedImports */ && namedBindings.elements.length === 0) { - return ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); - }); - } - return undefined; - } - case 2 /* Namespace */: - return namedBindings ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamespaceImport(ts.createIdentifier(symbolName)))); - }); - case 3 /* Equals */: - return undefined; - default: - ts.Debug.assertNever(importKind); - } + function getFixesInfo(context, errorCode, pos) { + var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos); + var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getFixesInfoForUMDImport(context, symbolToken) + : getFixesInfoForNonUMDImport(context, symbolToken); + return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix, context, symbolToken) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - var changes = ChangeTracker.with(context, function (tracker) { - return tracker.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); - }); - return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); + function getFixesInfoForUMDImport(_a, token) { + var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; + var checker = program.getTypeChecker(); + var umdSymbol = getUmdSymbol(token, checker); + if (!umdSymbol) + return undefined; + var symbol = checker.getAliasedSymbol(umdSymbol); + var symbolName = umdSymbol.name; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()) }]; + var fixes = getFixForImport(exportInfos, symbolName, token, program, sourceFile, host, preferences); + return { fixes: fixes, symbolName: symbolName }; } - function getActionsForUMDImport(context) { - var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); - var checker = context.program.getTypeChecker(); - var umdSymbol; - if (ts.isIdentifier(token)) { - // try the identifier to see if it is the umd symbol - umdSymbol = checker.getSymbolAtLocation(token); - } - if (!ts.isUMDExportSymbol(umdSymbol)) { - // 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 === 260 /* JsxOpeningFragment */) { - umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); - } - } - if (ts.isUMDExportSymbol(umdSymbol)) { - var symbol = checker.getAliasedSymbol(umdSymbol); - if (symbol) { - return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(context.program.getCompilerOptions()) }], convertToImportCodeFixContext(context, token, umdSymbol.name)); - } - } - return undefined; + function getUmdSymbol(token, checker) { + // try the identifier to see if it is the umd symbol + var umdSymbol = ts.isIdentifier(token) ? checker.getSymbolAtLocation(token) : undefined; + if (ts.isUMDExportSymbol(umdSymbol)) + return umdSymbol; + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + var parent = token.parent; + return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67216319 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + : undefined; } function getUmdImportKind(compilerOptions) { // Import a synthetic `default` if enabled. @@ -103846,11 +104793,10 @@ var ts; return ts.Debug.assertNever(moduleKind); } } - function getActionsForNonUMDImport(context) { + function getFixesInfoForNonUMDImport(_a, symbolToken) { + var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. - var sourceFile = context.sourceFile, span = context.span, program = context.program, cancellationToken = context.cancellationToken; var checker = program.getTypeChecker(); - var symbolToken = ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false); // If we're at ``, we must check if `Foo` is already in scope, and if so, get an import for `React` instead. var symbolName = ts.isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken @@ -103860,14 +104806,14 @@ var ts; if (!symbolName) 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 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); + ts.Debug.assert(symbolName !== "default" /* Default */); + var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + var _ = _a[0], exportInfos = _a[1]; + return getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences); + })); + return { fixes: fixes, symbolName: symbolName }; } + // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, 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). @@ -103880,35 +104826,121 @@ var ts; // check the default export var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) { - var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); - if ((localSymbol && localSymbol.escapedName === symbolName || - getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target) === symbolName) && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { - addSymbol(moduleSymbol, localSymbol || defaultExport, 1 /* Default */); + var info = getDefaultExportInfo(defaultExport, moduleSymbol, program); + if (info && info.name === symbolName && symbolHasMeaning(info.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultExport, 1 /* Default */); } } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } - function getEscapedNameForExportDefault(symbol) { - return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { - if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.escapedText; - } - } - else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - return declaration.propertyName && declaration.propertyName.escapedText; - } - }); - } }); return originalSymbolToExportInfos; } - function checkSymbolHasMeaning(_a, meaning) { + function getDefaultExportInfo(defaultExport, moduleSymbol, program) { + var checker = program.getTypeChecker(); + var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) + return { symbolForMeaning: localSymbol, name: localSymbol.name }; + var name = getNameForExportDefault(defaultExport); + if (name !== undefined) + return { symbolForMeaning: defaultExport, name: name }; + if (defaultExport.flags & 2097152 /* Alias */) { + var aliased = checker.getAliasedSymbol(defaultExport); + return getDefaultExportInfo(aliased, ts.Debug.assertDefined(aliased.parent), program); + } + else { + var moduleName = moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target); + return moduleName === undefined ? undefined : { symbolForMeaning: defaultExport, name: moduleName }; + } + } + function getNameForExportDefault(symbol) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + if (ts.isExportAssignment(declaration)) { + if (ts.isIdentifier(declaration.expression)) { + return declaration.expression.text; + } + } + else if (ts.isExportSpecifier(declaration)) { + ts.Debug.assert(declaration.name.text === "default" /* Default */); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } + function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) { + var diag; + var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { + diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference); + }); + return codefix.createCodeFixAction("import", changes, diag, codefix.importFixId, ts.Diagnostics.Add_all_missing_imports); + } + function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) { + switch (fix.kind) { + case 0 /* UseNamespace */: + addNamespaceQualifier(changes, sourceFile, fix); + return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + doAddExistingFix(changes, sourceFile, importClause, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(importClause.parent.moduleSpecifier.getText()); + return [ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; + } + case 2 /* AddNew */: { + var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier; + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === 1 /* Default */ ? { defaultImport: symbolName, namedImports: ts.emptyArray, namespaceLikeImport: undefined } + : importKind === 0 /* Named */ ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined } + : { defaultImport: undefined, namedImports: ts.emptyArray, namespaceLikeImport: { importKind: importKind, name: symbolName } }); + return [ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; + } + default: + return ts.Debug.assertNever(fix); + } + } + function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { + if (defaultImport) { + ts.Debug.assert(!clause.name); + changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); + } + if (namedImports.length) { + var specifiers = namedImports.map(function (name) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); }); + if (clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements.length) { + for (var _i = 0, specifiers_1 = specifiers; _i < specifiers_1.length; _i++) { + var spec = specifiers_1[_i]; + changes.insertNodeInListAfter(sourceFile, ts.last(ts.cast(clause.namedBindings, ts.isNamedImports).elements), spec); + } + } + else { + if (specifiers.length) { + var namedImports_1 = ts.createNamedImports(specifiers); + if (clause.namedBindings) { + changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); + } + else { + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + } + } + } + } + } + function addNamespaceQualifier(changes, sourceFile, _a) { + var namespacePrefix = _a.namespacePrefix, symbolToken = _a.symbolToken; + changes.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); + } + function addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, _a) { + var defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport; + var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); + if (defaultImport !== undefined || namedImports.length) { + ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); + } + if (namespaceLikeImport) { + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ + ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) + : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + } + } + function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } @@ -104009,7 +105041,7 @@ var ts; // This is the identifier of the misspelled word. eg: // this.speling = 1; // ^^^^^^^ - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); // TODO: GH#15852 + var node = ts.getTokenAtPosition(sourceFile, pos); var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { @@ -104081,46 +105113,99 @@ var ts; var info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, context.preferences); + if (info.kind === InfoKind.enum) { + var token_1 = info.token, parentDeclaration_1 = info.parentDeclaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), token_1, parentDeclaration_1); }); + return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_missing_enum_member_0, token_1.text], fixId, ts.Diagnostics.Add_all_missing_members)]; + } + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); var addMember = inJs ? - ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, token.text, makeStatic)) : - getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, classDeclaration, token, makeStatic); + ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic)) : + getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, parentDeclaration, token, makeStatic); return ts.concatenate(ts.singleElementArray(methodCodeAction), addMember); }, fixIds: [fixId], getAllCodeActions: function (context) { - var seenNames = ts.createMap(); - return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var program = context.program, preferences = context.preferences; - var info = getInfo(diag.file, diag.start, program.getTypeChecker()); - if (!info) - return; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - if (!ts.addToSeen(seenNames, token.text)) { - return; - } - // Always prefer to add a method declaration if possible. - if (call) { - addMethodDeclaration(changes, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, preferences); - } - else { - if (inJs) { - addMissingMemberInJs(changes, classDeclarationSourceFile, classDeclaration, token.text, makeStatic); + var program = context.program, preferences = context.preferences; + var checker = program.getTypeChecker(); + var seen = ts.createMap(); + var classToMembers = new ts.NodeMap(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(diag.file, diag.start, checker); + if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { + return; + } + if (info.kind === InfoKind.enum) { + var token = info.token, parentDeclaration = info.parentDeclaration; + addEnumMemberDeclaration(changes, checker, token, parentDeclaration); } else { - var typeNode = getTypeNode(program.getTypeChecker(), classDeclaration, token); - addPropertyDeclaration(changes, classDeclarationSourceFile, classDeclaration, token.text, typeNode, makeStatic); + var parentDeclaration = info.parentDeclaration, token_2 = info.token; + var infos = classToMembers.getOrUpdate(parentDeclaration, function () { return []; }); + if (!infos.some(function (i) { return i.token.text === token_2.text; })) + infos.push(info); } - } - }); + }); + classToMembers.forEach(function (infos, classDeclaration) { + var superClasses = getAllSuperClasses(classDeclaration, checker); + var _loop_23 = function (info) { + // If some superclass added this property, don't add it again. + if (superClasses.some(function (superClass) { + var superInfos = classToMembers.get(superClass); + return !!superInfos && superInfos.some(function (_a) { + var token = _a.token; + return token.text === info.token.text; + }); + })) + return "continue"; + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + // Always prefer to add a method declaration if possible. + if (call) { + addMethodDeclaration(context, changes, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + } + else { + if (inJs) { + addMissingMemberInJs(changes, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic); + } + else { + var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token); + addPropertyDeclaration(changes, classDeclarationSourceFile, parentDeclaration, token.text, typeNode, makeStatic); + } + } + }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + _loop_23(info); + } + }); + })); }, }); + function getAllSuperClasses(cls, checker) { + var res = []; + while (cls) { + var superElement = ts.getClassExtendsHeritageElement(cls); + var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); + var superDecl = superSymbol && ts.find(superSymbol.declarations, ts.isClassLike); + if (superDecl) { + res.push(superDecl); + } + cls = superDecl; + } + return res; + } + var InfoKind; + (function (InfoKind) { + InfoKind[InfoKind["enum"] = 0] = "enum"; + InfoKind[InfoKind["class"] = 1] = "class"; + })(InfoKind || (InfoKind = {})); function getInfo(tokenSourceFile, tokenPos, checker) { // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ - var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos); if (!ts.isIdentifier(token)) { return undefined; } @@ -104129,14 +105214,21 @@ var ts; return undefined; var leftExpressionType = ts.skipConstraint(checker.getTypeAtLocation(parent.expression)); var symbol = leftExpressionType.symbol; - var classDeclaration = symbol && symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); - if (!classDeclaration) + if (!symbol || !symbol.declarations) return undefined; - var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); - var classDeclarationSourceFile = classDeclaration.getSourceFile(); - var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); - var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { token: token, classDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); + if (classDeclaration) { + var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); + var classDeclarationSourceFile = classDeclaration.getSourceFile(); + var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); + var call = ts.tryCast(parent.parent, ts.isCallExpression); + return { kind: InfoKind.class, token: token, parentDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + } + var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); + if (enumDeclaration) { + return { kind: InfoKind.enum, token: token, parentDeclaration: enumDeclaration }; + } + return undefined; } function getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic); }); @@ -104145,7 +105237,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 205 /* ClassExpression */) { + if (classDeclaration.kind === 207 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -104171,7 +105263,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 200 /* BinaryExpression */) { + if (token.parent.parent.kind === 202 /* 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))); // TODO: GH#18217 @@ -104225,11 +105317,11 @@ var ts; return codefix.createCodeFixActionNoFixId(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]); } function getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, token.text], fixId, ts.Diagnostics.Add_all_missing_members); } - function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); + function addMethodDeclaration(context, changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { + var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences); var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); @@ -104238,6 +105330,19 @@ var ts; changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); } } + function addEnumMemberDeclaration(changes, checker, token, enumDeclaration) { + /** + * create initializer only literal enum that has string initializer. + * value of initializer is a string literal that equal to name of enum member. + * numeric enum or empty enum will not create initializer. + */ + var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { + var type = checker.getTypeAtLocation(member); + return !!(type && type.flags & 68 /* StringLike */); + }); + var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); + changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104271,7 +105376,7 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function getTypesPackageNameToInstall(host, sourceFile, pos, diagCode) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), ts.isStringLiteral).text; + var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) @@ -104312,11 +105417,11 @@ var ts; function getClass(sourceFile, pos) { // Token is the identifier in the case of a class declaration // or the class keyword token in the case of a class expression. - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.cast(token.parent, ts.isClassLike); } function addMissingMembers(classDeclaration, sourceFile, checker, changeTracker, preferences) { - var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var extendsNode = ts.getEffectiveBaseTypeNode(classDeclaration); var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. @@ -104366,10 +105471,10 @@ var ts; }); function doChange(changes, sourceFile, constructor, superCall) { changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall); - changes.deleteNode(sourceFile, superCall); + changes.delete(sourceFile, superCall); } function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); if (token.kind !== 99 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); @@ -104408,7 +105513,7 @@ var ts; }); }, }); function getNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); return token.parent; } @@ -104444,7 +105549,7 @@ var ts; }); }, }); function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; @@ -104500,7 +105605,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos, diagCode) { - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(node)) return undefined; return { node: node, className: diagCode === didYouMeanStaticMemberCode ? ts.getContainingClass(node).name.text : undefined }; @@ -104534,25 +105639,30 @@ var ts; getCodeActions: function (context) { 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); + var sourceFiles = program.getSourceFiles(); + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var importDecl = tryGetFullImport(token); if (importDecl) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(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, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteFullDestructure(token, t, sourceFile, checker, sourceFiles, /*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); }); + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(sourceFile, token, t); }); 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, checker, /*isFixAll*/ false); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteDeclaration(sourceFile, token, t, checker, sourceFiles, /*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)); + var name = ts.isComputedPropertyName(token.parent) ? token.parent : token; + result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, name.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } var prefix = ts.textChanges.ChangeTracker.with(context, function (t) { return tryPrefixDeclaration(t, errorCode, sourceFile, token); }); if (prefix.length) { @@ -104562,32 +105672,28 @@ 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 ts.NodeSet(); var sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); + var sourceFiles = program.getSourceFiles(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); - var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); + var token = ts.getTokenAtPosition(sourceFile, diag.start); switch (context.fixId) { case fixIdPrefix: if (ts.isIdentifier(token) && canPrefix(token)) { tryPrefixDeclaration(changes, diag.code, sourceFile, token); } break; - case fixIdDelete: - // Ignore if this range was already deleted. - if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) - break; - var importDecl = tryGetFullImport(startToken); + case fixIdDelete: { + var importDecl = tryGetFullImport(token); if (importDecl) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } - else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && - !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); + else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(sourceFile, token, changes)) { + tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, /*isFixAll*/ true); } break; + } default: ts.Debug.fail(JSON.stringify(context.fixId)); } @@ -104595,49 +105701,29 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(startToken) { - return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; + function tryGetFullImport(token) { + return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { - if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) + function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { + if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; - var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; - switch (decl.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(decl, checker, isFixAll)) - break; - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNodeInList(sourceFile, decl); - break; - case 182 /* BindingElement */: - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNode(sourceFile, decl); - break; - default: - return ts.Debug.assertNever(decl); + var decl = token.parent.parent; + if (decl.kind === 149 /* Parameter */) { + tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); + } + else { + changes.delete(sourceFile, decl); } 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); + function tryDeleteFullVariableStatement(sourceFile, token, changes) { + var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { + changes.delete(sourceFile, declarationList.parent.kind === 217 /* 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; - return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token; - } function tryPrefixDeclaration(changes, errorCode, sourceFile, token) { // Don't offer to prefix a property. if (errorCode !== ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code && ts.isIdentifier(token) && canPrefix(token)) { @@ -104648,209 +105734,61 @@ var ts; switch (token.parent.kind) { case 149 /* Parameter */: return true; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { - tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll); + function tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, isFixAll) { + tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll); if (ts.isIdentifier(token)) deleteAssignments(changes, sourceFile, token, checker); } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 185 /* PropertyAccessExpression */) + if (ref.parent.kind === 187 /* PropertyAccessExpression */) ref = ref.parent; - if (ref.parent.kind === 200 /* BinaryExpression */ && ref.parent.parent.kind === 216 /* ExpressionStatement */) { - changes.deleteNode(sourceFile, ref.parent.parent); + if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + changes.delete(sourceFile, ref.parent.parent); } }); } - function tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { + function tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll) { var parent = token.parent; - switch (parent.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); - break; - 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; - var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false); - var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false); - ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); - ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); - changes.deleteNodeRange(sourceFile, previousToken, nextToken); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - 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, // 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. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 182 /* BindingElement */: { - var pattern = parent.parent; - var preserveComma = pattern.kind === 181 /* ArrayBindingPattern */ && parent !== ts.last(pattern.elements); - if (preserveComma) { - changes.deleteNode(sourceFile, parent); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - } - // handle case where 'import a = A;' - case 243 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(token, 243 /* ImportEqualsDeclaration */); - changes.deleteNode(sourceFile, importEquals); - break; - case 248 /* ImportSpecifier */: - var namedImports = parent.parent; - if (namedImports.elements.length === 1) { - tryDeleteNamedImportBinding(changes, sourceFile, namedImports); - } - else { - // delete import specifier - changes.deleteNodeInList(sourceFile, parent); - } - break; - 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, 244 /* ImportDeclaration */)); - } - else { - // import |d,| * as ns from './file' - var start = importClause.name.getStart(sourceFile); - var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end, /*includeJsDocComment*/ false); - if (nextToken && nextToken.kind === 26 /* CommaToken */) { - // shift first non-whitespace position after comma to the start position of the node - var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); - changes.deleteRange(sourceFile, { pos: start, end: end }); - } - else { - changes.deleteNode(sourceFile, importClause.name); - } - } - break; - case 246 /* NamespaceImport */: - tryDeleteNamedImportBinding(changes, sourceFile, parent); - break; - default: - if (ts.isDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent); - changes.deleteNode(sourceFile, token.parent); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent.parent); - changes.deleteNode(sourceFile, token.parent.parent); - } - break; - } - } - function tryDeleteNamedImportBinding(changes, sourceFile, namedBindings) { - if (namedBindings.parent.name) { - // Delete named imports while preserving the default import - // import d|, * as ns| from './file' - // import d|, { a }| from './file' - var previousToken = ts.getTokenAtPosition(sourceFile, namedBindings.pos - 1, /*includeJsDocComment*/ false); - if (previousToken && previousToken.kind === 26 /* CommaToken */) { - changes.deleteRange(sourceFile, { pos: previousToken.getStart(), end: namedBindings.end }); - } + if (ts.isParameter(parent)) { + tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, isFixAll); } else { - // Delete the entire import declaration - // |import * as ns from './file'| - // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); } } - // token.parent is a variableDeclaration - function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { - switch (varDecl.parent.parent.kind) { - case 220 /* ForStatement */: { - var forStatement = varDecl.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(forInitializer); - changes.deleteNode(sourceFile, forInitializer); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } - break; - } - case 222 /* ForOfStatement */: - var forOfStatement = varDecl.parent.parent; - 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 221 /* ForInStatement */: - case 230 /* TryStatement */: - break; - default: - var variableStatement = varDecl.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(variableStatement); - changes.deleteNode(sourceFile, variableStatement); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } + function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { + if (mayDeleteParameter(p, checker, isFixAll)) { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { case 154 /* MethodDeclaration */: - // Don't remove a parameter if this overrides something + // 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. + case 237 /* FunctionDeclaration */: + return true; + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: { + // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); @@ -104865,6 +105803,14 @@ var ts; return ts.Debug.failBadSyntaxKind(parent); } } + function deleteUnusedArguments(changes, sourceFile, deletedParameter, sourceFiles, checker) { + ts.FindAllReferences.Core.eachSignatureCall(deletedParameter.parent, sourceFiles, checker, function (call) { + var index = deletedParameter.parent.parameters.indexOf(deletedParameter); + if (call.arguments.length > index) { // Just in case the call didn't provide enough arguments. + changes.delete(sourceFile, call.arguments[index]); + } + }); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104884,12 +105830,12 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -104900,16 +105846,16 @@ var ts; break; } // falls through - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - changes.deleteNode(sourceFile, container); + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + changes.delete(sourceFile, container); break; default: if (ts.isBlock(statement.parent)) { split(sliceAfter(statement.parent.statements, statement), shouldRemove, function (start, end) { return changes.deleteNodeRange(sourceFile, start, end); }); } else { - changes.deleteNode(sourceFile, statement); + changes.delete(sourceFile, statement); } } } @@ -104921,12 +105867,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -104960,7 +105906,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var labeledStatement = ts.cast(token.parent, ts.isLabeledStatement); var pos = token.getStart(sourceFile); var statementPos = labeledStatement.statement.getStart(sourceFile); @@ -104990,7 +105936,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 281 /* JSDocNullableType */) { + if (typeNode.kind === 284 /* 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, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -105010,7 +105956,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -105019,7 +105965,7 @@ var ts; 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); + var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), isTypeContainer); var typeNode = decl && decl.type; return typeNode && { typeNode: typeNode, type: checker.getTypeFromTypeNode(typeNode) }; } @@ -105027,22 +105973,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 208 /* AsExpression */: + case 210 /* AsExpression */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 156 /* GetAccessor */: case 160 /* IndexSignature */: - case 177 /* MappedType */: + case 179 /* 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 */: + case 240 /* TypeAliasDeclaration */: + case 192 /* TypeAssertionExpression */: + case 235 /* VariableDeclaration */: return true; default: return false; @@ -105089,7 +106035,7 @@ var ts; } } function getNodes(sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var containingFunction = ts.getContainingFunction(token); if (!containingFunction) { return; @@ -105099,11 +106045,11 @@ var ts; case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -105273,8 +106219,22 @@ var ts; signatureDeclaration.body = body; return signatureDeclaration; } - function createMethodFromCallExpression(_a, methodName, inJs, makeStatic, preferences) { + function createMethodFromCallExpression(context, _a, methodName, inJs, makeStatic, preferences) { var typeArguments = _a.typeArguments, args = _a.arguments, parent = _a.parent; + var checker = context.program.getTypeChecker(); + var types = ts.map(args, function (arg) { + var type = checker.getTypeAtLocation(arg); + if (type === undefined) { + return undefined; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + type = checker.getBaseTypeOfLiteralType(type); + return checker.typeToTypeNode(type); + }); + var names = ts.map(args, function (arg) { + return ts.isIdentifier(arg) ? arg.text : + ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + }); return ts.createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, @@ -105283,11 +106243,11 @@ var ts; /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); }), - /*parameters*/ createDummyParameters(args.length, /*names*/ undefined, /*minArgumentCount*/ undefined, inJs), + /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), createStubbedMethodBody(preferences)); } codefix.createMethodFromCallExpression = createMethodFromCallExpression; - function createDummyParameters(argCount, names, minArgumentCount, inJs) { + function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; for (var i = 0; i < argCount; i++) { var newParameter = ts.createParameter( @@ -105296,7 +106256,7 @@ var ts; /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -105322,7 +106282,7 @@ var ts; } var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); - var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*inJs*/ false); + var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); var restParameter = ts.createParameter( @@ -105386,18 +106346,19 @@ var ts; if (ts.isSourceFileJavaScript(sourceFile)) { return undefined; // TODO: GH#20113 } - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var declaration; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeenseen*/ ts.returnTrue); }); - return changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getNameOfDeclaration(declaration).getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start, /*includeJsDocComment*/ false), err.code, program, cancellationToken, markSeen); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen); }); }, }); @@ -105479,11 +106440,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return !!declaration.name; } return false; @@ -105543,8 +106504,8 @@ var ts; function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? @@ -105612,21 +106573,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -105634,13 +106595,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 232 /* VariableDeclaration */: { + case 235 /* 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. @@ -105749,7 +106710,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -105777,7 +106738,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 187 /* CallExpression */) { + if (parent.kind === 189 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -105945,8 +106906,8 @@ 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 ? 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); }); + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -105973,7 +106934,7 @@ var ts; }); function getActionsForInvalidImportLocation(context) { var sourceFile = context.sourceFile; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -106048,7 +107009,7 @@ var ts; }, }); function getPropertyDeclaration(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined; } function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) { @@ -106133,7 +107094,7 @@ var ts; : ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, name, ts.createExternalModuleReference(required))); } function getInfo(sourceFile, pos) { - var parent = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false).parent; + var parent = ts.getTokenAtPosition(sourceFile, pos).parent; if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ true)) throw ts.Debug.failBadSyntaxKind(parent); var decl = ts.cast(parent.parent, ts.isVariableDeclaration); @@ -106166,7 +107127,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos) { - var name = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(name)) return undefined; // bad input var parent = name.parent; @@ -106190,7 +107151,7 @@ var ts; (function (codefix) { var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof"; var fixId = fixIdAddMissingTypeof; - var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code]; + var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { @@ -106205,9 +107166,9 @@ var ts; }); }, }); function getImportTypeNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 179 /* ImportType */); + ts.Debug.assert(token.parent.kind === 181 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -106243,7 +107204,7 @@ var ts; }); } }); function getInfo(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); if (ts.isClassDeclaration(indexSignature.parent)) return undefined; @@ -106272,129 +107233,325 @@ 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) + var refactorName = "Convert export"; + var actionNameDefaultToNamed = "Convert default export to named export"; + var actionNameNamedToDefault = "Convert named export to default export"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var info = getInfo(context); + if (!info) + return undefined; + var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; + var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + }, + }); + function getInfo(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var exportNode = ts.getParentNodeInSpan(token, file, span); + if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { + return undefined; + } + var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; + var flags = ts.getModifierFlags(exportNode); + var wasDefault = !!(flags & 512 /* Default */); + // If source file already has a default export, don't offer refactor. + if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + return undefined; + } + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: { + var node = exportNode; + return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + case 217 /* VariableStatement */: { + var vs = exportNode; + // Must be `export const x = something;`. + if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { 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 }; + } + var decl = ts.first(vs.declarationList.declarations); + if (!decl.initializer) + return undefined; + ts.Debug.assert(!wasDefault); + return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + default: + return undefined; + } + } + function doChange(exportingSourceFile, program, info, changes, cancellationToken) { + changeExport(exportingSourceFile, info, changes, program.getTypeChecker()); + changeImports(program, info, changes, cancellationToken); + } + function changeExport(exportingSourceFile, _a, changes, checker) { + var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; + if (wasDefault) { + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + } + else { + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + break; + case 217 /* VariableStatement */: + // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` + if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { + // We checked in `getInfo` that an initializer exists. + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + break; + } + // falls through + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: + // `export type T = number;` -> `type T = number; export default T;` + changes.deleteModifier(exportingSourceFile, exportKeyword); + changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); + break; + default: + ts.Debug.assertNever(exportNode); + } + } + } + function changeImports(program, _a, changes, cancellationToken) { + var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; + var checker = program.getTypeChecker(); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { + var importingSourceFile = ref.getSourceFile(); + if (wasDefault) { + changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text); + } + else { + changeNamedToDefaultImport(importingSourceFile, ref, changes); } }); - // 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())); + } + function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.default` --> `a.foo` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + // `default as foo` --> `foo`, `default as bar` --> `foo as bar` + changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); + break; } - 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; + case 248 /* ImportClause */: { + var clause = parent; + ts.Debug.assert(clause.name === ref); + var spec = makeImportSpecifier(exportName, ref.text); + var namedBindings = clause.namedBindings; + if (!namedBindings) { + // `import foo from "./a";` --> `import { foo } from "./a";` + changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); + } + else if (namedBindings.kind === 249 /* NamespaceImport */) { + // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` + changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); + changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } 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); + // `import foo, { bar } from "./a"` --> `import { bar, foo } from "./a";` + changes.delete(importingSourceFile, ref); + changes.insertNodeAtEndOfList(importingSourceFile, namedBindings.elements, spec); } - }); - // 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)); + break; } + default: + ts.Debug.failBadSyntaxKind(parent); } - 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_23 = 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))); - } + } + function changeNamedToDefaultImport(importingSourceFile, ref, changes) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.foo` --> `a.default` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + if (spec.kind === 251 /* ImportSpecifier */) { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(spec.name.text); + if (spec.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, spec.parent, defaultImport); } else { - changes.replaceNode(sourceFile, id, access); + changes.delete(importingSourceFile, spec); + changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); } - }); - }; - for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { - var element = _a[_i]; - _loop_23(element); + } + else { + // `export { foo } from "./a";` --> `export { default as foo } from "./a";` + // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` + // `export { foo as default } from "./a";` --> `export { default } from "./a";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + } + break; } - changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); - if (neededNamedImports.length) { - changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + default: + ts.Debug.failBadSyntaxKind(parent); + } + } + function makeImportSpecifier(propertyName, name) { + return ts.createImportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + function makeExportSpecifier(propertyName, name) { + return ts.createExportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + 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 === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 249 /* 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); + 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 === 249 /* 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)); } - function updateImport(old, defaultImportName, elements) { - return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + 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)); } - })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + 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_24 = 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_24(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); + } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); /* @internal */ @@ -106552,7 +107709,7 @@ 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 = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start), sourceFile, span); // Do the same for the ending position var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; @@ -106705,7 +107862,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 235 /* 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`! @@ -106717,13 +107874,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* 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 === 187 /* CallExpression */) { + if (node.parent.kind === 189 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -106738,8 +107895,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -106751,20 +107908,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 213 /* Block */: - if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { + case 216 /* Block */: + if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -106776,11 +107933,11 @@ var ts; break; } switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -106788,8 +107945,8 @@ var ts; seenLabels.pop(); break; } - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: { var label = node.label; if (label) { @@ -106799,20 +107956,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -106877,7 +108034,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 274 /* SourceFile */) { + if (current.kind === 277 /* SourceFile */) { return scopes; } } @@ -106969,12 +108126,12 @@ var ts; switch (scope.kind) { case 155 /* Constructor */: return "constructor"; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return "arrow function"; case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); @@ -106987,12 +108144,12 @@ var ts; } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 235 /* ClassDeclaration */ + return scope.kind === 238 /* 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 === 240 /* ModuleBlock */ + return scope.kind === 243 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -107271,7 +108428,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 216 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 219 /* 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( @@ -107290,9 +108447,9 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 216 /* ExpressionStatement */) { + if (node.parent.kind === 219 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. - changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); + changeTracker.delete(context.file, node.parent); } else { var localReference = ts.createIdentifier(localNameText); @@ -107377,7 +108534,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -107555,7 +108712,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 !== 234 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -107618,7 +108775,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_24 = function (i) { + var _loop_25 = 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 @@ -107658,7 +108815,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_24(i); + _loop_25(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -107871,30 +109028,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 273 /* EnumMember */: + case 276 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return parent.kind !== 244 /* ImportDeclaration */ && - parent.kind !== 248 /* ImportSpecifier */; - case 204 /* SpreadElement */: - case 180 /* ObjectBindingPattern */: - case 182 /* BindingElement */: + return parent.kind !== 247 /* ImportDeclaration */ && + parent.kind !== 251 /* ImportSpecifier */; + case 206 /* SpreadElement */: + case 182 /* ObjectBindingPattern */: + case 184 /* BindingElement */: return false; case 71 /* Identifier */: - return parent.kind !== 182 /* BindingElement */ && - parent.kind !== 248 /* ImportSpecifier */ && - parent.kind !== 252 /* ExportSpecifier */; + return parent.kind !== 184 /* BindingElement */ && + parent.kind !== 251 /* ImportSpecifier */ && + parent.kind !== 255 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 213 /* Block */: - case 274 /* SourceFile */: - case 240 /* ModuleBlock */: - case 266 /* CaseClause */: + case 216 /* Block */: + case 277 /* SourceFile */: + case 243 /* ModuleBlock */: + case 269 /* CaseClause */: return true; default: return false; @@ -107914,8 +109071,7 @@ var ts; var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { - var file = context.file; - if (!getConvertibleFieldAtPosition(context, file)) + if (!getConvertibleFieldAtPosition(context)) return undefined; return [{ name: actionName, @@ -107930,7 +109086,7 @@ var ts; } function getEditsForAction(context, _actionName) { var file = context.file; - var fieldInfo = getConvertibleFieldAtPosition(context, file); + var fieldInfo = getConvertibleFieldAtPosition(context); if (!fieldInfo) return undefined; var isJS = ts.isSourceFileJavaScript(file); @@ -107991,13 +109147,13 @@ var ts; function startsWithUnderscore(name) { return name.charCodeAt(0) === 95 /* _ */; } - function getConvertibleFieldAtPosition(context, file) { - var startPosition = context.startPosition, endPosition = context.endPosition; - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + function getConvertibleFieldAtPosition(context) { + var file = context.file, startPosition = context.startPosition, endPosition = context.endPosition; + var node = ts.getTokenAtPosition(file, startPosition); 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) // TODO: GH#18217 + if (!declaration || !ts.nodeOverlapsWithStartEnd(declaration.name, file, startPosition, endPosition) // TODO: GH#18217 || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; @@ -108152,11 +109308,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return true; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -108209,10 +109365,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_25 = function (sourceFile) { + var _loop_26 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_26 = function (statement) { + var _loop_27 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -108234,22 +109390,22 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_26(statement); + _loop_27(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_25(sourceFile); + _loop_26(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + case 247 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -108280,20 +109436,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -108363,15 +109519,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -108384,23 +109540,23 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } else { if (name && defaultUnused) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } if (namedBindings) { if (namedBindingsUnused) { - changes.deleteNode(sourceFile, namedBindings); + changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 247 /* NamedImports */) { + else if (namedBindings.kind === 250 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) - changes.deleteNodeInList(sourceFile, element); + changes.delete(sourceFile, element); } } } @@ -108411,20 +109567,20 @@ var ts; switch (name.kind) { case 71 /* Identifier */: if (isUnused(name)) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: break; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); + changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } else { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (ts.isIdentifier(element.name) && isUnused(element.name)) { - changes.deleteNode(sourceFile, element.name); + changes.delete(sourceFile, element.name); } } } @@ -108521,13 +109677,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: return true; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -108539,7 +109695,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -108549,9 +109705,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -108560,7 +109716,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -108572,9 +109728,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return name; - case 180 /* ObjectBindingPattern */: { + case 182 /* 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; @@ -108631,13 +109787,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -108645,17 +109801,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return cb(statement); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -108664,7 +109820,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -108696,23 +109852,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -108723,18 +109879,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -108809,7 +109965,7 @@ var ts; return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(file, startPosition); var func = ts.getContainingFunction(node); if (!func || !ts.isArrowFunction(func) || (!ts.rangeContainsRange(func, node) || ts.rangeContainsRange(func.body, node))) return undefined; @@ -108915,7 +110071,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 299 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 302 /* LastJSDocNode */; }); return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -108985,7 +110141,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(300 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(303 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -109042,7 +110198,7 @@ var ts; return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { - return ts.emptyArray; + return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -109296,7 +110452,7 @@ var ts; }; SourceFileObject.prototype.computeNamedDeclarations = function () { var result = ts.createMultiMap(); - ts.forEachChild(this, visit); + this.forEachChild(visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); @@ -109312,14 +110468,14 @@ var ts; return declarations; } function getDeclarationName(declaration) { - var name = ts.getNameOfDeclaration(declaration); + var name = ts.getNonAssignedNameOfDeclaration(declaration); return name && (ts.isComputedPropertyName(name) && ts.isPropertyAccessExpression(name.expression) ? name.expression.name.text : ts.isPropertyName(name) ? ts.getNameFromPropertyName(name) : undefined); } function visit(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: var functionDeclaration = node; @@ -109341,17 +110497,17 @@ var ts; } ts.forEachChild(node, visit); break; - 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 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 166 /* TypeLiteral */: @@ -109364,8 +110520,8 @@ var ts; break; } // falls through - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: { + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -109376,31 +110532,31 @@ var ts; } } // falls through - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: addDeclaration(node); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addDeclaration(importClause); + addDeclaration(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -109409,7 +110565,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -109777,7 +110933,7 @@ var ts; readFile: function (fileName) { // stub missing host functionality var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); if (entry) { return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot); } @@ -109827,7 +110983,7 @@ var ts; return; function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : (!!host.fileExists && host.fileExists(fileName)); @@ -109842,11 +110998,11 @@ var ts; return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); } function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { - ts.Debug.assert(hostCache !== undefined); + ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined // to the program to allow reporting of errors for missing files. - var hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path); + var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path); if (!hostFileInformation) { return undefined; } @@ -109942,17 +111098,17 @@ var ts; return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { - if (options === void 0) { options = ts.defaultPreferences; } + if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 - getCanonicalFileName, preferences, cancellationToken); + preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -109977,10 +111133,10 @@ var ts; return undefined; } // falls through - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_4 = typeChecker.getTypeAtLocation(node); @@ -110025,7 +111181,8 @@ var ts; 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]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; function scanForSourcemapURL(fileName) { var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); @@ -110034,11 +111191,15 @@ var ts; } var starts = ts.getLineStarts(mappedFile); for (var index = starts.length - 1; index >= 0; index--) { - sourceMapCommentRegExp.lastIndex = starts[index]; - var comment = sourceMapCommentRegExp.exec(mappedFile.text); + var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); + var comment = sourceMapCommentRegExp.exec(lineText); if (comment) { return comment[1]; } + // If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!lineText.match(whitespaceOrMapCommentRegExp)) { + break; + } } } function convertDocumentToSourceMapper(file, contents, mapFileName) { @@ -110192,18 +111353,32 @@ var ts; return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; + return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); }); + } + else { + var refs = getReferences(node, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + return refs && refs.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + return ({ fileName: fileName, textSpan: textSpan }); + }); + } } function getReferencesAtPosition(fileName, position) { - return getReferences(fileName, position); + synchronizeHostData(); + return getReferences(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position); } - function getReferences(fileName, position, options) { + function getReferences(node, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. 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); + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -110227,10 +111402,11 @@ var ts; /** * This is a semantic operation. */ - function getSignatureHelpItems(fileName, position) { + function getSignatureHelpItems(fileName, position, _a) { + var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); } /// Syntactic features function getNonBoundSourceFile(fileName) { @@ -110244,7 +111420,7 @@ var ts; return undefined; } switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: @@ -110252,7 +111428,7 @@ var ts; case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span @@ -110269,7 +111445,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 === 239 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 242 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -110339,7 +111515,7 @@ var ts; braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var token = ts.getTouchingToken(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, position); var matchKind = token.getStart(sourceFile) === position ? braceMatching.get(token.kind.toString()) : undefined; var match = matchKind && ts.findChildOfKind(token.parent, matchKind, sourceFile); // We want to order the braces when we return the result. @@ -110380,7 +111556,7 @@ var ts; return []; } function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = ts.createTextSpanFromBounds(start, end); @@ -110391,7 +111567,7 @@ var ts; }); } function getCombinedCodeFix(scope, fixId, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110399,7 +111575,7 @@ var ts; return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } function organizeImports(scope, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110407,7 +111583,7 @@ var ts; return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { @@ -110470,8 +111646,8 @@ var ts; } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); - return range && ts.createTextSpanFromRange(range); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); + return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -110599,8 +111775,7 @@ var ts; } function getRenameInfo(fileName, position) { synchronizeHostData(); - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - return ts.Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); + return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position); } function getRefactorContext(file, positionOrRange, preferences, formatOptions) { var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1]; @@ -110616,13 +111791,13 @@ var ts; }; } function getApplicableRefactors(fileName, positionOrRange, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getApplicableRefactors(getRefactorContext(file, positionOrRange, preferences)); } function getEditsForRefactor(fileName, formatOptions, positionOrRange, refactorName, actionName, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); @@ -110716,7 +111891,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 254 /* ExternalModuleReference */ || + node.parent.kind === 257 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -110734,7 +111909,7 @@ var ts; // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && + (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -110773,7 +111948,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 186 /* ElementAccessExpression */ && + node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -110804,7 +111979,7 @@ var ts; if (sourceFile.isDeclarationFile) { return undefined; } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { // Get previous token if the token is returned starts on new line @@ -110853,114 +112028,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return spanInVariableDeclaration(node); case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanInBlock(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInBlock(node.block); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 217 /* IfStatement */: + case 220 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return spanInForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 182 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 184 /* BindingElement */: // span on complete node return textSpan(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: // span in statement return spanInNode(node.statement); case 150 /* Decorator */: return spanInNodeArray(parent.decorators); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -111003,13 +112178,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 === 204 /* SpreadElement */ || - node.kind === 270 /* PropertyAssignment */ || - node.kind === 271 /* ShorthandPropertyAssignment */) && + node.kind === 206 /* SpreadElement */ || + node.kind === 273 /* PropertyAssignment */ || + node.kind === 274 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 200 /* BinaryExpression */) { + if (node.kind === 202 /* 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 @@ -111031,22 +112206,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: return textSpan(node); - case 200 /* BinaryExpression */: + case 202 /* 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 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -111055,20 +112230,20 @@ var ts; } } switch (node.parent.kind) { - case 270 /* PropertyAssignment */: + case 273 /* 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 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; @@ -111077,7 +112252,7 @@ var ts; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -111107,7 +112282,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -111119,7 +112294,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 222 /* ForOfStatement */) { + parent.parent.kind === 225 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -111160,7 +112335,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -111183,26 +112358,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 221 /* ForInStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 224 /* 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 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 236 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -111227,21 +112402,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 182 /* BindingElement */) { + if (bindingPattern.parent.kind === 184 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - 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; }); + ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); + var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -111249,18 +112424,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 === 200 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 202 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -111268,25 +112443,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 240 /* ModuleBlock */: + case 243 /* 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 238 /* EnumDeclaration */: - case 235 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -111294,7 +112469,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); @@ -111310,7 +112485,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 181 /* ArrayBindingPattern */: + case 183 /* 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); @@ -111325,12 +112500,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 187 /* CallExpression */ || - node.parent.kind === 188 /* NewExpression */) { + if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 189 /* CallExpression */ || + node.parent.kind === 190 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 191 /* ParenthesizedExpression */) { + if (node.parent.kind === 193 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -111339,21 +112514,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* 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 */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 193 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -111363,20 +112538,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 273 /* PropertyAssignment */ || node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 190 /* TypeAssertionExpression */) { + if (node.parent.kind === 192 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 218 /* DoStatement */) { + if (node.parent.kind === 221 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -111384,7 +112559,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.kind === 225 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -111804,9 +112979,9 @@ var ts; return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 6046364b40a..3e74564a556 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -16,31 +16,67 @@ and limitations under the License. "use strict"; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); }; "use strict"; -var __assign = (this && this.__assign) || Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + 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; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } - return t; }; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } @@ -892,23 +928,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1869,8 +1888,9 @@ 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; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2210,160 +2230,163 @@ var ts; 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["OptionalType"] = 169] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; // Expression - 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["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; // Element - 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["Block"] = 216] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; // JSX - 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["JsxElement"] = 258] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; // The ? type - 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["JSDocThisTag"] = 295] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 296] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 297] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 298] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 299] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 296] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 297] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 298] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 299] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 300] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 301] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 302] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 300] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 303] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 301] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 302] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 303] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 304] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 305] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 304] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 305] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 306] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 307] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 308] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 306] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 309] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -2376,7 +2399,7 @@ var ts; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; @@ -2390,10 +2413,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 299] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 299] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 302] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 302] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -2567,6 +2590,7 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; @@ -2786,6 +2810,8 @@ var ts; CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; CheckFlags[CheckFlags["Late"] = 1024] = "Late"; CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped"; + CheckFlags[CheckFlags["OptionalParameter"] = 4096] = "OptionalParameter"; + CheckFlags[CheckFlags["RestParameter"] = 8192] = "RestParameter"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var InternalSymbolName; @@ -4420,6 +4446,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -4578,7 +4607,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -4698,6 +4726,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -4728,7 +4758,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -4798,6 +4828,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -4847,6 +4878,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -4994,6 +5026,9 @@ var ts; 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'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), 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."), @@ -5080,6 +5115,8 @@ var ts; 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}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), 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}'."), @@ -5379,6 +5416,10 @@ var ts; 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), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), 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}"), @@ -5410,6 +5451,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -5441,6 +5484,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -5585,6 +5629,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -7733,7 +7781,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274 /* SourceFile */) { + while (node && node.kind !== 277 /* SourceFile */) { node = node.parent; } return node; @@ -7741,11 +7789,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return true; } return false; @@ -7883,7 +7931,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 === 300 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 303 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7976,14 +8024,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { @@ -7997,7 +8037,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; + return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -8029,11 +8069,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 === 239 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 /* SourceFile */ || - node.kind === 239 /* ModuleDeclaration */ || + return node.kind === 277 /* SourceFile */ || + node.kind === 242 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8050,9 +8090,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 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node.parent); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8064,22 +8104,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 269 /* CatchClause */: - case 239 /* ModuleDeclaration */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 272 /* CatchClause */: + case 242 /* ModuleDeclaration */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; - case 213 /* Block */: + case 216 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8095,22 +8135,22 @@ var ts; 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 297 /* JSDocTemplateTag */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: - case 288 /* JSDocSignature */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 291 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -8120,8 +8160,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8130,15 +8170,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - 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 */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 217 /* VariableStatement */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -8159,7 +8199,7 @@ var ts; // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -8186,7 +8226,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8231,7 +8271,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213 /* Block */) { + if (node.body && node.body.kind === 216 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8245,7 +8285,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* 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 @@ -8254,25 +8294,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 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 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: errorNode = node.name; break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8304,35 +8344,34 @@ var ts; return file.scriptKind === 6 /* JSON */; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */ && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */) - || !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 /* ImportType */ && - n.argument.kind === 178 /* LiteralType */ && + return n.kind === 181 /* ImportType */ && + n.argument.kind === 180 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 /* ExpressionStatement */ + return node.kind === 219 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -8343,9 +8382,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 /* Parameter */ || node.kind === 148 /* TypeParameter */ || - node.kind === 192 /* FunctionExpression */ || - node.kind === 193 /* ArrowFunction */ || - node.kind === 191 /* ParenthesizedExpression */) ? + node.kind === 194 /* FunctionExpression */ || + node.kind === 195 /* ArrowFunction */ || + node.kind === 193 /* 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 '/**/' @@ -8361,7 +8400,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -8375,11 +8414,11 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 196 /* VoidExpression */; - case 207 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 198 /* VoidExpression */; + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148 /* TypeParameter */: - return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; + return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: @@ -8387,20 +8426,20 @@ var ts; if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 187 /* 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 === 146 /* QualifiedName */ || node.kind === 185 /* 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 === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through case 146 /* QualifiedName */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: { var parent = node.parent; if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 179 /* ImportType */) { + if (parent.kind === 181 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8409,22 +8448,22 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148 /* TypeParameter */: return node === parent.constraint; case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return node === parent.type; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -8435,12 +8474,12 @@ var ts; case 159 /* ConstructSignature */: case 160 /* IndexSignature */: return node === parent.type; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return node === parent.type; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8465,23 +8504,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitor(node); - 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 */: + case 244 /* CaseBlock */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8491,19 +8530,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -8546,12 +8585,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 166 /* TypeLiteral */: return node.members; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.properties; } } @@ -8559,14 +8598,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182 /* BindingElement */: - case 273 /* EnumMember */: + case 184 /* BindingElement */: + case 276 /* EnumMember */: case 149 /* Parameter */: - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 271 /* ShorthandPropertyAssignment */: - case 232 /* VariableDeclaration */: + case 274 /* ShorthandPropertyAssignment */: + case 235 /* VariableDeclaration */: return true; } } @@ -8578,12 +8617,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 /* VariableDeclarationList */ - && node.parent.parent.kind === 214 /* VariableStatement */; + return node.parent.kind === 236 /* VariableDeclarationList */ + && node.parent.parent.kind === 217 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -8595,8 +8634,8 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return true; } return false; @@ -8607,7 +8646,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228 /* LabeledStatement */) { + if (node.statement.kind !== 231 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -8615,17 +8654,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 184 /* ObjectLiteralExpression */ || - node.parent.kind === 205 /* ClassExpression */); + (node.parent.kind === 186 /* ObjectLiteralExpression */ || + node.parent.kind === 207 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8638,7 +8677,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270 /* PropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -8675,7 +8714,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274 /* SourceFile */); + ts.Debug.assert(node.kind !== 277 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -8710,14 +8749,14 @@ var ts; node = node.parent; } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 239 /* ModuleDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 242 /* ModuleDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 154 /* MethodDeclaration */: @@ -8728,8 +8767,8 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 238 /* EnumDeclaration */: - case 274 /* SourceFile */: + case 241 /* EnumDeclaration */: + case 277 /* SourceFile */: return node; } } @@ -8740,8 +8779,8 @@ var ts; if (container) { switch (container.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return container; } } @@ -8766,9 +8805,9 @@ var ts; case 147 /* ComputedPropertyName */: node = node.parent; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!stopOnFunctions) { continue; } @@ -8799,14 +8838,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { + if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 191 /* ParenthesizedExpression */) { + while (parent.kind === 193 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -8817,7 +8856,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -8826,7 +8865,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -8834,7 +8873,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -8847,10 +8886,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return node.tag; - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -8859,25 +8898,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // classes are valid targets return true; case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 235 /* ClassDeclaration */; + return parent.kind === 238 /* 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 === 235 /* ClassDeclaration */; + && parent.kind === 238 /* 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 === 155 /* Constructor */ || parent.kind === 154 /* MethodDeclaration */ || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 235 /* ClassDeclaration */; + && grandparent.kind === 238 /* ClassDeclaration */; } return false; } @@ -8893,7 +8932,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 case 154 /* MethodDeclaration */: case 157 /* SetAccessor */: @@ -8905,9 +8944,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 /* JsxOpeningElement */ || - parent.kind === 256 /* JsxSelfClosingElement */ || - parent.kind === 258 /* JsxClosingElement */) { + if (parent.kind === 260 /* JsxOpeningElement */ || + parent.kind === 259 /* JsxSelfClosingElement */ || + parent.kind === 261 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -8920,37 +8959,37 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - 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 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: + case 210 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 211 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 206 /* SpreadElement */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 206 /* OmittedExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 203 /* YieldExpression */: - case 197 /* AwaitExpression */: - case 210 /* MetaProperty */: + case 208 /* OmittedExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 205 /* YieldExpression */: + case 199 /* AwaitExpression */: + case 212 /* MetaProperty */: return true; case 146 /* QualifiedName */: while (node.parent.kind === 146 /* QualifiedName */) { @@ -8974,47 +9013,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 182 /* BindingElement */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 184 /* BindingElement */: return parent.initializer === node; - 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 */: + case 219 /* ExpressionStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 228 /* ReturnStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 232 /* ThrowStatement */: return parent.expression === node; - case 220 /* ForStatement */: + case 223 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forInStatement.expression === node; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return node === parent.expression; - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return node === parent.expression; case 147 /* ComputedPropertyName */: return node === parent.expression; case 150 /* Decorator */: - case 265 /* JsxExpression */: - case 264 /* JsxSpreadAttribute */: - case 272 /* SpreadAssignment */: + case 268 /* JsxExpression */: + case 267 /* JsxSpreadAttribute */: + case 275 /* SpreadAssignment */: return true; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -9022,7 +9061,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9031,7 +9070,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -9063,7 +9102,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187 /* CallExpression */) { + if (callExpression.kind !== 189 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -9159,11 +9198,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 192 /* FunctionExpression */ || - initializer.kind === 205 /* ClassExpression */ || - initializer.kind === 193 /* ArrowFunction */) { + if (initializer.kind === 194 /* FunctionExpression */ || + initializer.kind === 207 /* ClassExpression */ || + initializer.kind === 195 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9232,7 +9271,7 @@ var ts; return false; } function getRightMostAssignedExpression(node) { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -9255,6 +9294,14 @@ var ts; return 0 /* None */; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + // F.prototype = { ... } + return 6 /* Prototype */; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } @@ -9263,11 +9310,7 @@ var ts; return 2 /* ModuleExports */; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - // F.prototype = { ... } - return 6 /* Prototype */; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } @@ -9287,7 +9330,7 @@ var ts; } return 0 /* None */; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -9301,7 +9344,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9311,14 +9354,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.parent; - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return node.parent.parent; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return node.parent; - case 178 /* LiteralType */: + case 180 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9328,12 +9371,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.moduleSpecifier; - case 243 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 179 /* ImportType */: + case 246 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 181 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9342,11 +9385,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9354,7 +9397,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -9363,8 +9406,8 @@ var ts; case 149 /* Parameter */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 271 /* ShorthandPropertyAssignment */: - case 270 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return node.questionToken !== undefined; @@ -9374,14 +9417,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 /* JSDocFunctionType */ && + return node.kind === 287 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 301 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9406,12 +9449,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152 /* PropertyDeclaration */: return node.initializer; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return node.initializer; } } @@ -9421,59 +9464,57 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 /* ModuleDeclaration */ + node.body.kind === 242 /* ModuleDeclaration */ ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - 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. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } - } - // Pull parameter comments from declaring function as well - 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)) { - result = ts.addRange(result, node.initializer.jsDoc); - } + // Pull parameter comments from declaring function as well + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } + if (node.kind === 149 /* Parameter */) { + result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; + } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 /* PropertyAssignment */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + return parent; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -9522,7 +9563,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9535,31 +9576,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 191 /* ParenthesizedExpression */: - case 183 /* ArrayLiteralExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 185 /* ArrayLiteralExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: node = parent; break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -9586,22 +9627,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - 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 */: + case 216 /* Block */: + case 217 /* VariableStatement */: + case 229 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return true; } return false; @@ -9618,15 +9659,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173 /* ParenthesizedType */); + return walkUp(node, 175 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191 /* ParenthesizedExpression */); + return walkUp(node, 193 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */) { + while (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -9634,11 +9675,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 !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194 /* DeleteExpression */; + return node && node.kind === 196 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9695,9 +9736,9 @@ var ts; case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 185 /* PropertyAccessExpression */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 187 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; case 146 /* QualifiedName */: @@ -9709,12 +9750,12 @@ var ts; return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 182 /* BindingElement */: - case 248 /* ImportSpecifier */: + case 184 /* BindingElement */: + case 251 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 252 /* ExportSpecifier */: - case 262 /* JsxAttribute */: + case 255 /* ExportSpecifier */: + case 265 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -9730,13 +9771,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(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) || + return node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 245 /* NamespaceExportDeclaration */ || + node.kind === 248 /* ImportClause */ && !!node.name || + node.kind === 249 /* NamespaceImport */ || + node.kind === 251 /* ImportSpecifier */ || + node.kind === 255 /* ExportSpecifier */ || + node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9745,11 +9786,22 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + // Prefer an @augments tag because it may have type parameters. + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; @@ -9758,7 +9810,7 @@ var ts; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -9831,14 +9883,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -9852,9 +9904,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined @@ -9960,7 +10012,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182 /* BindingElement */) { + while (node.kind === 184 /* BindingElement */) { node = node.parent.parent; } return node; @@ -9969,14 +10021,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 /* Constructor */ - || kind === 192 /* FunctionExpression */ - || kind === 234 /* FunctionDeclaration */ - || kind === 193 /* ArrowFunction */ + || kind === 194 /* FunctionExpression */ + || kind === 237 /* FunctionDeclaration */ + || kind === 195 /* ArrowFunction */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ - || kind === 239 /* ModuleDeclaration */ - || kind === 274 /* SourceFile */; + || kind === 242 /* ModuleDeclaration */ + || kind === 277 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9995,23 +10047,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: return 1 /* Right */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -10035,15 +10087,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200 /* BinaryExpression */) { + if (expression.kind === 202 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { + else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10053,15 +10105,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return 0; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return 1; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return 2; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return 4; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -10082,21 +10134,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: return 16; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return 17; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return 18; - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 19 : 18; - case 189 /* TaggedTemplateExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 191 /* TaggedTemplateExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -10106,19 +10158,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - 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 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 191 /* ParenthesizedExpression */: - case 206 /* OmittedExpression */: + case 204 /* TemplateExpression */: + case 193 /* ParenthesizedExpression */: + case 208 /* OmittedExpression */: return 20; default: return -1; @@ -10177,6 +10229,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -10184,6 +10237,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -10606,7 +10676,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 289 /* 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); @@ -10618,7 +10688,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -10911,8 +10981,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 184 /* ObjectLiteralExpression */ - || kind === 183 /* ArrayLiteralExpression */; + return kind === 186 /* ObjectLiteralExpression */ + || kind === 185 /* ArrayLiteralExpression */; } return false; } @@ -10922,7 +10992,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */ + return node.kind === 209 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -10944,16 +11014,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); + (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 /* ObjectLiteralExpression */ && + return expression.kind === 186 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 /* ArrayLiteralExpression */ && + return expression.kind === 185 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11294,8 +11364,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11372,21 +11442,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 185 /* PropertyAccessExpression */: + case 187 /* 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 === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -11489,7 +11559,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -11559,6 +11629,11 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + /* @internal */ + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; // Returns true if 'span' contains 'other'. function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -11752,7 +11827,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { return current; } } @@ -11777,27 +11852,34 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232 /* VariableDeclaration */) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236 /* VariableDeclarationList */) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217 /* VariableStatement */) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags @@ -11807,19 +11889,7 @@ var ts; // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** @@ -11927,16 +11997,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -11953,17 +12013,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return expr.name; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11972,10 +12032,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 228 /* LabeledStatement */: { + case 231 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11987,7 +12047,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -11998,29 +12058,20 @@ 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; - } + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71 /* Identifier */: return declaration; - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: { + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -12032,17 +12083,22 @@ var ts; return undefined; } } - case 292 /* JSDocCallbackTag */: - return declaration.name; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -12331,545 +12387,545 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169 /* UnionType */; + return node.kind === 171 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170 /* IntersectionType */; + return node.kind === 172 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171 /* ConditionalType */; + return node.kind === 173 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172 /* InferType */; + return node.kind === 174 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173 /* ParenthesizedType */; + return node.kind === 175 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174 /* ThisType */; + return node.kind === 176 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175 /* TypeOperator */; + return node.kind === 177 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176 /* IndexedAccessType */; + return node.kind === 178 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177 /* MappedType */; + return node.kind === 179 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178 /* LiteralType */; + return node.kind === 180 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179 /* ImportType */; + return node.kind === 181 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 180 /* ObjectBindingPattern */; + return node.kind === 182 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181 /* ArrayBindingPattern */; + return node.kind === 183 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182 /* BindingElement */; + return node.kind === 184 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 183 /* ArrayLiteralExpression */; + return node.kind === 185 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184 /* ObjectLiteralExpression */; + return node.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185 /* PropertyAccessExpression */; + return node.kind === 187 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186 /* ElementAccessExpression */; + return node.kind === 188 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187 /* CallExpression */; + return node.kind === 189 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188 /* NewExpression */; + return node.kind === 190 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189 /* TaggedTemplateExpression */; + return node.kind === 191 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190 /* TypeAssertionExpression */; + return node.kind === 192 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191 /* ParenthesizedExpression */; + return node.kind === 193 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302 /* PartiallyEmittedExpression */) { + while (node.kind === 305 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192 /* FunctionExpression */; + return node.kind === 194 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193 /* ArrowFunction */; + return node.kind === 195 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194 /* DeleteExpression */; + return node.kind === 196 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195 /* TypeOfExpression */; + return node.kind === 197 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196 /* VoidExpression */; + return node.kind === 198 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197 /* AwaitExpression */; + return node.kind === 199 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198 /* PrefixUnaryExpression */; + return node.kind === 200 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199 /* PostfixUnaryExpression */; + return node.kind === 201 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200 /* BinaryExpression */; + return node.kind === 202 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201 /* ConditionalExpression */; + return node.kind === 203 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202 /* TemplateExpression */; + return node.kind === 204 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203 /* YieldExpression */; + return node.kind === 205 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204 /* SpreadElement */; + return node.kind === 206 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205 /* ClassExpression */; + return node.kind === 207 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206 /* OmittedExpression */; + return node.kind === 208 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208 /* AsExpression */; + return node.kind === 210 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209 /* NonNullExpression */; + return node.kind === 211 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210 /* MetaProperty */; + return node.kind === 212 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 211 /* TemplateSpan */; + return node.kind === 214 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212 /* SemicolonClassElement */; + return node.kind === 215 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 213 /* Block */; + return node.kind === 216 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214 /* VariableStatement */; + return node.kind === 217 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215 /* EmptyStatement */; + return node.kind === 218 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216 /* ExpressionStatement */; + return node.kind === 219 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217 /* IfStatement */; + return node.kind === 220 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218 /* DoStatement */; + return node.kind === 221 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219 /* WhileStatement */; + return node.kind === 222 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220 /* ForStatement */; + return node.kind === 223 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221 /* ForInStatement */; + return node.kind === 224 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222 /* ForOfStatement */; + return node.kind === 225 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223 /* ContinueStatement */; + return node.kind === 226 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224 /* BreakStatement */; + return node.kind === 227 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; + return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225 /* ReturnStatement */; + return node.kind === 228 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226 /* WithStatement */; + return node.kind === 229 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227 /* SwitchStatement */; + return node.kind === 230 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228 /* LabeledStatement */; + return node.kind === 231 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229 /* ThrowStatement */; + return node.kind === 232 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230 /* TryStatement */; + return node.kind === 233 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231 /* DebuggerStatement */; + return node.kind === 234 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232 /* VariableDeclaration */; + return node.kind === 235 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233 /* VariableDeclarationList */; + return node.kind === 236 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234 /* FunctionDeclaration */; + return node.kind === 237 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235 /* ClassDeclaration */; + return node.kind === 238 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236 /* InterfaceDeclaration */; + return node.kind === 239 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237 /* TypeAliasDeclaration */; + return node.kind === 240 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */; + return node.kind === 241 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */; + return node.kind === 242 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240 /* ModuleBlock */; + return node.kind === 243 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241 /* CaseBlock */; + return node.kind === 244 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242 /* NamespaceExportDeclaration */; + return node.kind === 245 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */; + return node.kind === 246 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244 /* ImportDeclaration */; + return node.kind === 247 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245 /* ImportClause */; + return node.kind === 248 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246 /* NamespaceImport */; + return node.kind === 249 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247 /* NamedImports */; + return node.kind === 250 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248 /* ImportSpecifier */; + return node.kind === 251 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249 /* ExportAssignment */; + return node.kind === 252 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250 /* ExportDeclaration */; + return node.kind === 253 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251 /* NamedExports */; + return node.kind === 254 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252 /* ExportSpecifier */; + return node.kind === 255 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253 /* MissingDeclaration */; + return node.kind === 256 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 254 /* ExternalModuleReference */; + return node.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 255 /* JsxElement */; + return node.kind === 258 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256 /* JsxSelfClosingElement */; + return node.kind === 259 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257 /* JsxOpeningElement */; + return node.kind === 260 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258 /* JsxClosingElement */; + return node.kind === 261 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259 /* JsxFragment */; + return node.kind === 262 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260 /* JsxOpeningFragment */; + return node.kind === 263 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261 /* JsxClosingFragment */; + return node.kind === 264 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262 /* JsxAttribute */; + return node.kind === 265 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263 /* JsxAttributes */; + return node.kind === 266 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264 /* JsxSpreadAttribute */; + return node.kind === 267 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265 /* JsxExpression */; + return node.kind === 268 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 266 /* CaseClause */; + return node.kind === 269 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267 /* DefaultClause */; + return node.kind === 270 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268 /* HeritageClause */; + return node.kind === 271 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269 /* CatchClause */; + return node.kind === 272 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 270 /* PropertyAssignment */; + return node.kind === 273 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271 /* ShorthandPropertyAssignment */; + return node.kind === 274 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272 /* SpreadAssignment */; + return node.kind === 275 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 274 /* SourceFile */; + return node.kind === 277 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275 /* Bundle */; + return node.kind === 278 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276 /* UnparsedSource */; + return node.kind === 279 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 278 /* JSDocTypeExpression */; + return node.kind === 281 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279 /* JSDocAllType */; + return node.kind === 282 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280 /* JSDocUnknownType */; + return node.kind === 283 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281 /* JSDocNullableType */; + return node.kind === 284 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282 /* JSDocNonNullableType */; + return node.kind === 285 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283 /* JSDocOptionalType */; + return node.kind === 286 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284 /* JSDocFunctionType */; + return node.kind === 287 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285 /* JSDocVariadicType */; + return node.kind === 288 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286 /* JSDocComment */; + return node.kind === 289 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290 /* JSDocAugmentsTag */; + return node.kind === 293 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291 /* JSDocClassTag */; + return node.kind === 294 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295 /* JSDocThisTag */; + return node.kind === 298 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293 /* JSDocParameterTag */; + return node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294 /* JSDocReturnTag */; + return node.kind === 297 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296 /* JSDocTypeTag */; + return node.kind === 299 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297 /* JSDocTemplateTag */; + return node.kind === 300 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298 /* JSDocTypedefTag */; + return node.kind === 301 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299 /* JSDocPropertyTag */; + return node.kind === 302 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; + return node.kind === 302 /* JSDocPropertyTag */ || node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287 /* JSDocTypeLiteral */; + return node.kind === 290 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288 /* JSDocSignature */; + return node.kind === 291 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -12880,7 +12936,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 300 /* SyntaxList */; + return n.kind === 303 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -12995,8 +13051,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 180 /* ObjectBindingPattern */ - || kind === 181 /* ArrayBindingPattern */; + || kind === 182 /* ObjectBindingPattern */ + || kind === 183 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13011,13 +13067,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; default: return false; @@ -13028,11 +13084,11 @@ var ts; switch (kind) { case 153 /* MethodSignature */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: case 164 /* ConstructorType */: return true; default: @@ -13054,11 +13110,11 @@ var ts; || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ || kind === 160 /* IndexSignature */ - || kind === 212 /* SemicolonClassElement */; + || kind === 215 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); + return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -13093,9 +13149,9 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 /* PropertyAssignment */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 272 /* SpreadAssignment */ + return kind === 273 /* PropertyAssignment */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 275 /* SpreadAssignment */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */; @@ -13103,7 +13159,7 @@ var ts; ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ @@ -13116,14 +13172,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 207 /* ExpressionWithTypeArguments */ - || kind === 279 /* JSDocAllType */ - || kind === 280 /* JSDocUnknownType */ - || kind === 281 /* JSDocNullableType */ - || kind === 282 /* JSDocNonNullableType */ - || kind === 283 /* JSDocOptionalType */ - || kind === 284 /* JSDocFunctionType */ - || kind === 285 /* JSDocVariadicType */; + || kind === 209 /* ExpressionWithTypeArguments */ + || kind === 282 /* JSDocAllType */ + || kind === 283 /* JSDocUnknownType */ + || kind === 284 /* JSDocNullableType */ + || kind === 285 /* JSDocNonNullableType */ + || kind === 286 /* JSDocOptionalType */ + || kind === 287 /* JSDocFunctionType */ + || kind === 288 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13148,8 +13204,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 /* ArrayBindingPattern */ - || kind === 180 /* ObjectBindingPattern */; + return kind === 183 /* ArrayBindingPattern */ + || kind === 182 /* ObjectBindingPattern */; } return false; } @@ -13157,15 +13213,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 /* ArrayLiteralExpression */ - || kind === 184 /* ObjectLiteralExpression */; + return kind === 185 /* ArrayLiteralExpression */ + || kind === 186 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 /* BindingElement */ - || kind === 206 /* OmittedExpression */; + return kind === 184 /* BindingElement */ + || kind === 208 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13174,9 +13230,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return true; } return false; @@ -13197,8 +13253,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return true; } return false; @@ -13210,8 +13266,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return true; } return false; @@ -13220,25 +13276,25 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */ - || kind === 179 /* ImportType */; + || kind === 181 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: case 150 /* Decorator */: return true; default: @@ -13247,12 +13303,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; + return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 /* TemplateExpression */ + return kind === 204 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13263,32 +13319,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - 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 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 190 /* NewExpression */: + case 189 /* CallExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 191 /* TaggedTemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 193 /* ParenthesizedExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 209 /* NonNullExpression */: - case 210 /* MetaProperty */: + case 211 /* NonNullExpression */: + case 212 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13302,13 +13358,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 190 /* TypeAssertionExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 192 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13317,9 +13373,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -13338,15 +13394,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: - case 193 /* ArrowFunction */: - case 200 /* BinaryExpression */: - case 204 /* SpreadElement */: - case 208 /* AsExpression */: - case 206 /* OmittedExpression */: - case 303 /* CommaListExpression */: - case 302 /* PartiallyEmittedExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: + case 195 /* ArrowFunction */: + case 202 /* BinaryExpression */: + case 206 /* SpreadElement */: + case 210 /* AsExpression */: + case 208 /* OmittedExpression */: + case 306 /* CommaListExpression */: + case 305 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13354,18 +13410,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 /* TypeAssertionExpression */ - || kind === 208 /* AsExpression */; + return kind === 192 /* TypeAssertionExpression */ + || kind === 210 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 302 /* PartiallyEmittedExpression */; + return node.kind === 305 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 301 /* NotEmittedStatement */; + return node.kind === 304 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -13376,13 +13432,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return true; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13390,7 +13446,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; + return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13414,113 +13470,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */ + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */; + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 239 /* ModuleDeclaration */; + || kind === 242 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 /* NamedImports */ - || kind === 246 /* NamespaceImport */; + return kind === 250 /* NamedImports */ + || kind === 249 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; + return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 /* ArrowFunction */ - || kind === 182 /* BindingElement */ - || kind === 235 /* ClassDeclaration */ - || kind === 205 /* ClassExpression */ + return kind === 195 /* ArrowFunction */ + || kind === 184 /* BindingElement */ + || kind === 238 /* ClassDeclaration */ + || kind === 207 /* ClassExpression */ || kind === 155 /* Constructor */ - || kind === 238 /* EnumDeclaration */ - || kind === 273 /* EnumMember */ - || kind === 252 /* ExportSpecifier */ - || kind === 234 /* FunctionDeclaration */ - || kind === 192 /* FunctionExpression */ + || kind === 241 /* EnumDeclaration */ + || kind === 276 /* EnumMember */ + || kind === 255 /* ExportSpecifier */ + || kind === 237 /* FunctionDeclaration */ + || kind === 194 /* FunctionExpression */ || kind === 156 /* GetAccessor */ - || kind === 245 /* ImportClause */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 248 /* ImportSpecifier */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 262 /* JsxAttribute */ + || kind === 248 /* ImportClause */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 251 /* ImportSpecifier */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 265 /* JsxAttribute */ || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ - || kind === 239 /* ModuleDeclaration */ - || kind === 242 /* NamespaceExportDeclaration */ - || kind === 246 /* NamespaceImport */ + || kind === 242 /* ModuleDeclaration */ + || kind === 245 /* NamespaceExportDeclaration */ + || kind === 249 /* NamespaceImport */ || kind === 149 /* Parameter */ - || kind === 270 /* PropertyAssignment */ + || kind === 273 /* PropertyAssignment */ || kind === 152 /* PropertyDeclaration */ || kind === 151 /* PropertySignature */ || kind === 157 /* SetAccessor */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 237 /* TypeAliasDeclaration */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 240 /* TypeAliasDeclaration */ || kind === 148 /* TypeParameter */ - || kind === 232 /* VariableDeclaration */ - || kind === 298 /* JSDocTypedefTag */ - || kind === 292 /* JSDocCallbackTag */ - || kind === 299 /* JSDocPropertyTag */; + || kind === 235 /* VariableDeclaration */ + || kind === 301 /* JSDocTypedefTag */ + || kind === 295 /* JSDocCallbackTag */ + || kind === 302 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - 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 */; + return kind === 237 /* FunctionDeclaration */ + || kind === 256 /* MissingDeclaration */ + || kind === 238 /* ClassDeclaration */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 240 /* TypeAliasDeclaration */ + || kind === 241 /* EnumDeclaration */ + || kind === 242 /* ModuleDeclaration */ + || kind === 247 /* ImportDeclaration */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 253 /* ExportDeclaration */ + || kind === 252 /* ExportAssignment */ + || kind === 245 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - 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 === 301 /* NotEmittedStatement */ - || kind === 305 /* EndOfDeclarationMarker */ - || kind === 304 /* MergeDeclarationMarker */; + return kind === 227 /* BreakStatement */ + || kind === 226 /* ContinueStatement */ + || kind === 234 /* DebuggerStatement */ + || kind === 221 /* DoStatement */ + || kind === 219 /* ExpressionStatement */ + || kind === 218 /* EmptyStatement */ + || kind === 224 /* ForInStatement */ + || kind === 225 /* ForOfStatement */ + || kind === 223 /* ForStatement */ + || kind === 220 /* IfStatement */ + || kind === 231 /* LabeledStatement */ + || kind === 228 /* ReturnStatement */ + || kind === 230 /* SwitchStatement */ + || kind === 232 /* ThrowStatement */ + || kind === 233 /* TryStatement */ + || kind === 217 /* VariableStatement */ + || kind === 222 /* WhileStatement */ + || kind === 229 /* WithStatement */ + || kind === 304 /* NotEmittedStatement */ + || kind === 308 /* EndOfDeclarationMarker */ + || kind === 307 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 297 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -13547,10 +13603,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213 /* Block */) + if (node.kind !== 216 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { + if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { return false; } } @@ -13560,7 +13616,7 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 254 /* ExternalModuleReference */ + return kind === 257 /* ExternalModuleReference */ || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } @@ -13571,62 +13627,62 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 185 /* PropertyAccessExpression */; + || kind === 187 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 255 /* JsxElement */ - || kind === 265 /* JsxExpression */ - || kind === 256 /* JsxSelfClosingElement */ + return kind === 258 /* JsxElement */ + || kind === 268 /* JsxExpression */ + || kind === 259 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 259 /* JsxFragment */; + || kind === 262 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 /* JsxAttribute */ - || kind === 264 /* JsxSpreadAttribute */; + return kind === 265 /* JsxAttribute */ + || kind === 267 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 265 /* JsxExpression */; + || kind === 268 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 /* JsxOpeningElement */ - || kind === 256 /* JsxSelfClosingElement */; + return kind === 260 /* JsxOpeningElement */ + || kind === 259 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 /* CaseClause */ - || kind === 267 /* DefaultClause */; + return kind === 269 /* CaseClause */ + || kind === 270 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 299 /* LastJSDocNode */; + return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 302 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 /* 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 >= 289 /* FirstJSDocTagNode */ && node.kind <= 299 /* LastJSDocTagNode */; + return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 302 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -13669,22 +13725,22 @@ var ts; 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 */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: + case 179 /* MappedType */: + case 192 /* TypeAssertionExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 210 /* AsExpression */: + case 235 /* VariableDeclaration */: + case 237 /* FunctionDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 281 /* JSDocTypeExpression */: + case 284 /* JSDocNullableType */: + case 285 /* JSDocNonNullableType */: + case 286 /* JSDocOptionalType */: + case 287 /* JSDocFunctionType */: + case 288 /* JSDocVariadicType */: return true; } return false; @@ -13704,10 +13760,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -13719,7 +13775,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13756,7 +13812,7 @@ var ts; (function (ts) { /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; + return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -13897,6 +13953,13 @@ var ts; } /* @internal */ function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + /* @internal */ + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -13904,7 +13967,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; + } + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -14447,17 +14522,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.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; - } + function isDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; // Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. @@ -15010,7 +15083,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 274 /* SourceFile */) { + if (kind === 277 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -15074,14 +15147,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* 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 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -15106,20 +15179,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270 /* PropertyAssignment */: + case 273 /* 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 232 /* VariableDeclaration */: + case 235 /* 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 182 /* BindingElement */: + case 184 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15141,9 +15214,9 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15168,290 +15241,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172 /* InferType */: + case 174 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 179 /* ImportType */: + case 181 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: return visitNode(cbNode, node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177 /* MappedType */: + case 179 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return visitNode(cbNode, node.literal); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitNode(cbNode, node.name); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return visitNode(cbNode, node.label); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* 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 236 /* InterfaceDeclaration */: + case 239 /* 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 237 /* TypeAliasDeclaration */: + case 240 /* 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 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 278 /* JSDocTypeExpression */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 281 /* JSDocTypeExpression */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 286 /* JSDocOptionalType */: + case 288 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 282 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 281 /* JSDocNullableType */: - return visitNode(cbNode, node.type); - case 283 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 286 /* JSDocComment */: + case 289 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15460,17 +15531,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 278 /* JSDocTypeExpression */) { + node.typeExpression.kind === 281 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15478,18 +15549,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292 /* JSDocCallbackTag */: + case 295 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295 /* JSDocThisTag */: + case 298 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocSignature */: + case 291 /* 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 287 /* JSDocTypeLiteral */: + case 290 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15497,7 +15568,7 @@ var ts; } } return; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15711,7 +15782,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216 /* ExpressionStatement */); + var statement = createNode(219 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15828,13 +15899,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); // Should only be called once per node + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -15870,7 +15938,7 @@ 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(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16677,7 +16745,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 152 /* PropertyDeclaration */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return true; case 154 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -16694,8 +16762,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: return true; } } @@ -16704,42 +16772,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - 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 */: + case 237 /* FunctionDeclaration */: + case 217 /* VariableStatement */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 219 /* ExpressionStatement */: + case 232 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 230 /* SwitchStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 218 /* EmptyStatement */: + case 233 /* TryStatement */: + case 231 /* LabeledStatement */: + case 221 /* DoStatement */: + case 234 /* DebuggerStatement */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -16755,7 +16823,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232 /* VariableDeclaration */) { + if (node.kind !== 235 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16881,7 +16949,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -16943,7 +17016,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202 /* TemplateExpression */); + var template = createNode(204 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -16955,7 +17028,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211 /* TemplateSpan */); + var span = createNode(214 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -17021,10 +17094,9 @@ var ts; case 163 /* FunctionType */: case 164 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17038,14 +17110,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174 /* ThisType */); + var node = createNode(176 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279 /* JSDocAllType */); + var result = createNode(282 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, result); + return createPostfixType(286 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17053,7 +17125,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282 /* JSDocNonNullableType */); + var result = createNode(285 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17077,18 +17149,18 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(280 /* JSDocUnknownType */, pos); + var result = createNode(283 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(281 /* JSDocNullableType */, pos); + var result = createNode(284 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -17110,12 +17182,12 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, type); + return createPostfixType(286 /* JSDocOptionalType */, type); } return type; } @@ -17455,7 +17527,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177 /* MappedType */); + var node = createNode(179 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17477,13 +17549,26 @@ var ts; parseExpected(18 /* CloseBraceToken */); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24 /* DotDotDotToken */)) { + var node = createNode(170 /* RestType */, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 169 /* OptionalType */; + } + return type; + } function parseTupleType() { var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173 /* ParenthesizedType */); + var node = createNode(175 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); parseExpected(20 /* CloseParenToken */); @@ -17501,10 +17586,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178 /* LiteralType */); + var node = createNode(180 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17525,7 +17610,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(179 /* ImportType */); + var node = createNode(181 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17651,19 +17736,19 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); + type = createPostfixType(285 /* 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(281 /* JSDocNullableType */, type); + type = createPostfixType(284 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(176 /* IndexedAccessType */, type.pos); + var node = createNode(178 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); @@ -17682,21 +17767,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175 /* TypeOperator */); + var node = createNode(177 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172 /* InferType */); + var node = createNode(174 /* InferType */); parseExpected(126 /* InferKeyword */); var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); @@ -17729,10 +17814,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17816,7 +17901,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(171 /* ConditionalType */, type.pos); + var node = createNode(173 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -18009,7 +18094,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203 /* YieldExpression */); + var node = createNode(205 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -18031,11 +18116,11 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193 /* ArrowFunction */, asyncModifier.pos); + node = createNode(195 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193 /* ArrowFunction */, identifier.pos); + node = createNode(195 /* ArrowFunction */, identifier.pos); } var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; @@ -18233,7 +18318,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193 /* ArrowFunction */); + var node = createNodeWithJSDoc(195 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18297,7 +18382,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(201 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18377,39 +18462,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200 /* BinaryExpression */, left.pos); + var node = createNode(202 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208 /* AsExpression */, left.pos); + var node = createNode(210 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194 /* DeleteExpression */); + var node = createNode(196 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195 /* TypeOfExpression */); + var node = createNode(197 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196 /* VoidExpression */); + var node = createNode(198 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18425,7 +18510,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197 /* AwaitExpression */); + var node = createNode(199 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18469,7 +18554,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 192 /* 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 { @@ -18566,7 +18651,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18579,7 +18664,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18635,7 +18720,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(210 /* MetaProperty */, fullStart); + var node = createNode(212 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18710,7 +18795,7 @@ 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(185 /* PropertyAccessExpression */, expression.pos); + var node = createNode(187 /* 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); @@ -18719,8 +18804,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257 /* JsxOpeningElement */) { - var node = createNode(255 /* JsxElement */, opening.pos); + if (opening.kind === 260 /* JsxOpeningElement */) { + var node = createNode(258 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18729,15 +18814,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260 /* JsxOpeningFragment */) { - var node = createNode(259 /* JsxFragment */, opening.pos); + else if (opening.kind === 263 /* JsxOpeningFragment */) { + var node = createNode(262 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18752,7 +18837,7 @@ 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(200 /* BinaryExpression */, result.pos); + var badNode = createNode(202 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -18810,7 +18895,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263 /* JsxAttributes */); + var jsxAttributes = createNode(266 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18819,7 +18904,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18831,7 +18916,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(257 /* JsxOpeningElement */, fullStart); + node = createNode(260 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18843,7 +18928,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(256 /* JsxSelfClosingElement */, fullStart); + node = createNode(259 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18860,7 +18945,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18868,7 +18953,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265 /* JsxExpression */); + var node = createNode(268 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18890,7 +18975,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262 /* JsxAttribute */); + var node = createNode(265 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18905,7 +18990,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264 /* JsxSpreadAttribute */); + var node = createNode(267 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18913,7 +18998,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258 /* JsxClosingElement */); + var node = createNode(261 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18926,7 +19011,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261 /* JsxClosingFragment */); + var node = createNode(264 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18941,7 +19026,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190 /* TypeAssertionExpression */); + var node = createNode(192 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18952,7 +19037,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18960,14 +19045,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(211 /* 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(186 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(188 /* 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); @@ -18994,7 +19079,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -19018,7 +19103,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -19026,7 +19111,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19138,28 +19223,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204 /* SpreadElement */); + var node = createNode(206 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183 /* ArrayLiteralExpression */); + var node = createNode(185 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19171,7 +19256,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 272 /* SpreadAssignment */; + node.kind = 275 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19198,7 +19283,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 = 271 /* ShorthandPropertyAssignment */; + node.kind = 274 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -19206,14 +19291,14 @@ var ts; } } else { - node.kind = 270 /* PropertyAssignment */; + node.kind = 273 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184 /* ObjectLiteralExpression */); + var node = createNode(186 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19232,7 +19317,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(192 /* FunctionExpression */); + var node = createNodeWithJSDoc(194 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19257,7 +19342,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(210 /* MetaProperty */, fullStart); + var node_2 = createNode(212 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19274,7 +19359,7 @@ var ts; } break; } - var node = createNode(188 /* NewExpression */, fullStart); + var node = createNode(190 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19284,7 +19369,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213 /* Block */); + var node = createNode(216 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19317,12 +19402,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215 /* EmptyStatement */); + var node = createNode(218 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(217 /* IfStatement */); + var node = createNode(220 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19332,7 +19417,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218 /* DoStatement */); + var node = createNode(221 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19347,7 +19432,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219 /* WhileStatement */); + var node = createNode(222 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19371,7 +19456,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(222 /* ForOfStatement */, pos); + var forOfStatement = createNode(225 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19379,14 +19464,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(221 /* ForInStatement */, pos); + var forInStatement = createNode(224 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220 /* ForStatement */, pos); + var forStatement = createNode(223 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19404,7 +19489,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19412,7 +19497,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225 /* ReturnStatement */); + var node = createNode(228 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19421,7 +19506,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226 /* WithStatement */); + var node = createNode(229 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19430,7 +19515,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266 /* CaseClause */); + var node = createNode(269 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19438,7 +19523,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267 /* DefaultClause */); + var node = createNode(270 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19448,12 +19533,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227 /* SwitchStatement */); + var node = createNode(230 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(241 /* CaseBlock */); + var caseBlock = createNode(244 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19468,7 +19553,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(229 /* ThrowStatement */); + var node = createNode(232 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19476,7 +19561,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(230 /* TryStatement */); + var node = createNode(233 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19489,7 +19574,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269 /* CatchClause */); + var result = createNode(272 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19503,7 +19588,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231 /* DebuggerStatement */); + var node = createNode(234 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19515,12 +19600,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 228 /* LabeledStatement */; + node.kind = 231 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216 /* ExpressionStatement */; + node.kind = 219 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19687,16 +19772,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19706,9 +19791,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(223 /* ContinueStatement */); + return parseBreakOrContinueStatement(226 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(224 /* BreakStatement */); + return parseBreakOrContinueStatement(227 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19805,7 +19890,7 @@ 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(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -19828,16 +19913,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(206 /* OmittedExpression */); + return createNode(208 /* OmittedExpression */); } - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19853,14 +19938,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180 /* ObjectBindingPattern */); + var node = createNode(182 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181 /* ArrayBindingPattern */); + var node = createNode(183 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19882,7 +19967,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232 /* VariableDeclaration */); + var node = createNode(235 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19895,7 +19980,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233 /* VariableDeclarationList */); + var node = createNode(236 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19933,13 +20018,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 214 /* VariableStatement */; + node.kind = 217 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234 /* FunctionDeclaration */; + node.kind = 237 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -20121,7 +20206,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(212 /* SemicolonClassElement */); + var result = createNode(215 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -20158,10 +20243,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -20204,14 +20289,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(268 /* HeritageClause */); + var node = createNode(271 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -20228,7 +20313,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236 /* InterfaceDeclaration */; + node.kind = 239 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20237,7 +20322,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237 /* TypeAliasDeclaration */; + node.kind = 240 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20251,13 +20336,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(273 /* EnumMember */); + var node = createNodeWithJSDoc(276 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238 /* EnumDeclaration */; + node.kind = 241 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20270,7 +20355,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240 /* ModuleBlock */); + var node = createNode(243 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20281,7 +20366,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* 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 */; @@ -20293,7 +20378,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -20339,7 +20424,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 242 /* NamespaceExportDeclaration */; + node.kind = 245 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20357,7 +20442,7 @@ var ts; } } // Import statement - node.kind = 244 /* ImportDeclaration */; + node.kind = 247 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20372,7 +20457,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243 /* ImportEqualsDeclaration */; + node.kind = 246 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20386,7 +20471,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(245 /* ImportClause */, fullStart); + var importClause = createNode(248 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20396,7 +20481,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); } return finishNode(importClause); } @@ -20406,7 +20491,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(254 /* ExternalModuleReference */); + var node = createNode(257 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20429,7 +20514,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(246 /* NamespaceImport */); + var namespaceImport = createNode(249 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20444,14 +20529,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252 /* ExportSpecifier */); + return parseImportOrExportSpecifier(255 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248 /* ImportSpecifier */); + return parseImportOrExportSpecifier(251 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20476,19 +20561,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250 /* ExportDeclaration */; + node.kind = 253 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(254 /* 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. @@ -20501,7 +20586,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249 /* ExportAssignment */; + node.kind = 252 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20521,10 +20606,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ - || node.kind === 244 /* ImportDeclaration */ - || node.kind === 249 /* ExportAssignment */ - || node.kind === 250 /* ExportDeclaration */ + || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ + || node.kind === 247 /* ImportDeclaration */ + || node.kind === 252 /* ExportAssignment */ + || node.kind === 253 /* ExportDeclaration */ ? node : undefined; } @@ -20587,7 +20672,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20647,17 +20732,16 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var state = 1 /* SawAsterisk */; @@ -20743,9 +20827,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -20757,7 +20840,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286 /* JSDocComment */, start); + var result = createNode(289 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20874,6 +20957,16 @@ var ts; indent += whitespace.length; } break; + case 17 /* OpenBraceToken */: + state = 2 /* SavingComments */; + if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token @@ -20895,7 +20988,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289 /* JSDocTag */, atToken.pos); + var result = createNode(292 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20955,8 +21048,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(299 /* JSDocPropertyTag */, atToken.pos) : - createNode(293 /* JSDocParameterTag */, atToken.pos); + createNode(302 /* JSDocPropertyTag */, atToken.pos) : + createNode(296 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -20976,18 +21069,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281 /* 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 === 293 /* JSDocParameterTag */ || child.kind === 299 /* JSDocPropertyTag */) { + if (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -20998,27 +21091,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocReturnTag */, atToken.pos); + var result = createNode(297 /* 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 === 296 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296 /* JSDocTypeTag */, atToken.pos); + var result = createNode(299 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -21026,7 +21119,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -21038,7 +21131,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(185 /* PropertyAccessExpression */, node.pos); + var prop = createNode(187 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -21046,13 +21139,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291 /* JSDocClassTag */, atToken.pos); + var tag = createNode(294 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295 /* JSDocThisTag */, atToken.pos); + var tag = createNode(298 /* JSDocThisTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); @@ -21062,7 +21155,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(301 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21078,9 +21171,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 296 /* JSDocTypeTag */) { + if (child.kind === 299 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21112,7 +21205,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21126,7 +21219,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21135,7 +21228,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288 /* JSDocSignature */, start); + var jsdocSignature = createNode(291 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -21143,7 +21236,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 294 /* JSDocReturnTag */) { + if (tag && tag.kind === 297 /* JSDocReturnTag */) { return tag; } } @@ -21188,9 +21281,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 /* JSDocParameterTag */ && + if (child && (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -21264,7 +21357,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(300 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22068,6 +22161,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -23237,7 +23331,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 !== 270 /* PropertyAssignment */) { + if (element.kind !== 273 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -23314,13 +23408,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198 /* PrefixUnaryExpression */: + case 200 /* 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 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -23337,7 +23431,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25425,24 +25519,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 238 /* EnumDeclaration */: - if (ts.isConst(node)) { + case 241 /* EnumDeclaration */: + if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 240 /* ModuleBlock */: { + case 243 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -25464,7 +25558,7 @@ var ts; }); return state_1; } - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -25623,7 +25717,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 === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -25648,32 +25742,32 @@ var ts; return "__constructor" /* Constructor */; case 163 /* FunctionType */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return "__call" /* Call */; case 164 /* ConstructorType */: case 159 /* ConstructSignature */: return "__new" /* New */; case 160 /* IndexSignature */: return "__index" /* Index */; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); 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 === 284 /* 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 === 287 /* 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; @@ -25767,7 +25861,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 === 249 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 252 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -25792,7 +25886,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -25859,7 +25953,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 !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -25904,7 +25998,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -25953,8 +26047,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -25986,77 +26080,78 @@ var ts; return; } switch (node.kind) { - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: bindWhileStatement(node); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: bindDoStatement(node); break; - case 220 /* ForStatement */: + case 223 /* ForStatement */: bindForStatement(node); break; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: bindIfStatement(node); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: bindTryStatement(node); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: bindSwitchStatement(node); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: bindCaseBlock(node); break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: bindCaseClause(node); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: bindLabeledStatement(node); break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: bindCallExpressionFlow(node); break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 274 /* SourceFile */: + case 277 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213 /* Block */: - case 240 /* ModuleBlock */: + } + case 216 /* Block */: + case 243 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -26069,15 +26164,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return hasNarrowableArgument(expr); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -26086,7 +26181,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -26097,7 +26192,7 @@ var ts; } } } - if (expr.expression.kind === 185 /* PropertyAccessExpression */ && + if (expr.expression.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -26130,9 +26225,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -26210,33 +26305,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return parent.expression === node; - case 220 /* ForStatement */: - case 201 /* ConditionalExpression */: + case 223 /* ForStatement */: + case 203 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191 /* ParenthesizedExpression */) { + if (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 /* ParenthesizedExpression */ || - node.parent.kind === 198 /* PrefixUnaryExpression */ && + while (node.parent.kind === 193 /* ParenthesizedExpression */ || + node.parent.kind === 200 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -26278,7 +26373,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -26312,13 +26407,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222 /* ForOfStatement */) { + if (node.kind === 225 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233 /* VariableDeclarationList */) { + if (node.initializer.kind !== 236 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -26340,7 +26435,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225 /* ReturnStatement */) { + if (node.kind === 228 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -26360,7 +26455,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -26456,7 +26551,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* 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; @@ -26524,14 +26619,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -26542,10 +26637,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183 /* ArrayLiteralExpression */) { + else if (node.kind === 185 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204 /* SpreadElement */) { + if (e.kind === 206 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -26553,16 +26648,16 @@ var ts; } } } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270 /* PropertyAssignment */) { + if (p.kind === 273 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271 /* ShorthandPropertyAssignment */) { + else if (p.kind === 274 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272 /* SpreadAssignment */) { + else if (p.kind === 275 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -26618,7 +26713,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26629,7 +26724,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -26676,10 +26771,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 === 191 /* ParenthesizedExpression */) { + while (expr.kind === 193 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { + if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -26687,7 +26782,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26696,21 +26791,21 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 266 /* JsxAttributes */: return 1 /* IsContainer */; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 179 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -26718,32 +26813,32 @@ var ts; } // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: - case 284 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: case 163 /* FunctionType */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 269 /* CatchClause */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 241 /* CaseBlock */: + case 272 /* CatchClause */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 244 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 213 /* Block */: + case 216 /* 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 @@ -26776,20 +26871,20 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 184 /* ObjectLiteralExpression */: - case 236 /* InterfaceDeclaration */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 186 /* ObjectLiteralExpression */: + case 239 /* InterfaceDeclaration */: + case 266 /* 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 @@ -26800,21 +26895,21 @@ var ts; case 164 /* ConstructorType */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 288 /* JSDocSignature */: + case 291 /* 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 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 287 /* JSDocFunctionType */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 240 /* TypeAliasDeclaration */: + case 179 /* 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 @@ -26835,11 +26930,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { + var body = node.kind === 277 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { + if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { return true; } } @@ -26923,7 +27018,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 === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -26935,7 +27030,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 === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -26967,10 +27062,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -27111,8 +27206,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 274 /* SourceFile */ && - blockScopeContainer.kind !== 239 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 277 /* SourceFile */ && + blockScopeContainer.kind !== 242 /* 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. @@ -27208,7 +27303,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1 /* EndOfFileToken */) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -27266,11 +27365,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -27278,7 +27377,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -27306,19 +27405,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return checkStrictModeCatchClause(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkStrictModeWithStatement(node); - case 174 /* ThisType */: + case 176 /* ThisType */: seenThisKeyword = true; return; case 161 /* TypePredicate */: @@ -27327,18 +27426,18 @@ var ts; return bindTypeParameter(node); case 149 /* Parameter */: return bindParameter(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); case 158 /* CallSignature */: case 159 /* ConstructSignature */: @@ -27351,7 +27450,7 @@ var ts; // 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -27360,83 +27459,83 @@ var ts; case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 177 /* MappedType */: + case 290 /* JSDocTypeLiteral */: + case 179 /* MappedType */: return bindAnonymousTypeWorker(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return bindFunctionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return bindJsxAttributes(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return bindImportClause(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return bindExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return bindExportAssignment(node); - case 274 /* SourceFile */: + case 277 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213 /* Block */: + case 216 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 293 /* JSDocParameterTag */: - if (node.parent.kind === 288 /* JSDocSignature */) { + case 296 /* JSDocParameterTag */: + if (node.parent.kind === 291 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { break; } // falls through - case 299 /* JSDocPropertyTag */: + case 302 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -27468,7 +27567,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 /* 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 @@ -27482,7 +27581,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274 /* SourceFile */) { + if (node.parent.kind !== 277 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -27567,8 +27666,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 */) { @@ -27595,7 +27694,7 @@ var ts; 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 274 /* SourceFile */: + case 277 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -27607,7 +27706,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -27664,9 +27763,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + : propertyAccess.parent.parent.kind === 277 /* SourceFile */; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; @@ -27760,7 +27859,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -27793,7 +27892,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); } @@ -27823,7 +27922,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { + if (node.kind === 296 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -27900,7 +27999,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 172 /* InferType */) { + else if (node.parent.kind === 174 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -27928,13 +28027,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || // report error on class declarations - node.kind === 235 /* ClassDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -27991,43 +28090,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); @@ -28038,11 +28137,11 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -28094,12 +28193,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* 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 === 183 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -28148,8 +28247,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 === 208 /* AsExpression */ - || expressionKind === 190 /* TypeAssertionExpression */) { + if (expressionKind === 210 /* AsExpression */ + || expressionKind === 192 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -28526,13 +28625,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -28543,25 +28642,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 209 /* NonNullExpression */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 211 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: case 10 /* JsxText */: - case 258 /* JsxClosingElement */: - case 259 /* JsxFragment */: - case 260 /* JsxOpeningFragment */: - case 261 /* JsxClosingFragment */: - case 262 /* JsxAttribute */: - case 263 /* JsxAttributes */: - case 264 /* JsxSpreadAttribute */: - case 265 /* JsxExpression */: + case 261 /* JsxClosingElement */: + case 262 /* JsxFragment */: + case 263 /* JsxOpeningFragment */: + case 264 /* JsxClosingFragment */: + case 265 /* JsxAttribute */: + case 266 /* JsxAttributes */: + case 267 /* JsxSpreadAttribute */: + case 268 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -28569,11 +28668,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: - case 271 /* ShorthandPropertyAssignment */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 274 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -28587,14 +28686,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 222 /* ForOfStatement */: + case 225 /* 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 203 /* YieldExpression */: + case 205 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -28621,19 +28720,21 @@ var ts; 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 */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 174 /* InferType */: + case 175 /* ParenthesizedType */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: + case 245 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; @@ -28655,10 +28756,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -28670,18 +28771,18 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; @@ -28691,7 +28792,7 @@ var ts; // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -28709,8 +28810,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 183 /* ArrayLiteralExpression */: - case 188 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: + case 190 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -28718,26 +28819,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -28753,27 +28854,27 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 183 /* ArrayLiteralExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return 942011713 /* ClassExcludes */; case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; @@ -28795,24 +28896,24 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 269 /* CatchClause */: + case 272 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: - case 191 /* ParenthesizedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: + case 193 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -29101,6 +29202,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -29174,7 +29276,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -29272,6 +29373,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -29330,7 +29432,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -29387,6 +29489,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; /** @@ -29600,143 +29703,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - 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) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - 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)); // 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)); // TODO: GH#18217 - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896 /* TypeParameters */, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - 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)] : []; // 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)); })); // TODO: GH#18217 - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - 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)); // TODO: GH#18217 - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -29774,6 +29740,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -29899,22 +29890,57 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { - var message_2 = target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */ + var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); + var isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 /* LessThan */ ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -29989,7 +30015,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -30047,17 +30073,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 182 /* BindingElement */) { + if (declaration.kind === 184 /* 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, 182 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 184 /* 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, 232 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235 /* VariableDeclaration */), usage); } - else if (declaration.kind === 232 /* VariableDeclaration */) { + else if (declaration.kind === 235 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -30075,12 +30101,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 === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* 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 === 249 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 252 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -30088,9 +30114,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214 /* VariableStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 217 /* VariableStatement */: + case 223 /* ForStatement */: + case 225 /* 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)) { @@ -30162,7 +30188,7 @@ 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 !== 286 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -30182,7 +30208,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171 /* ConditionalType */) { + else if (location.kind === 173 /* 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; @@ -30196,14 +30222,14 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 277 /* 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 */)) { @@ -30227,7 +30253,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { break; } } @@ -30241,7 +30267,7 @@ var ts; } } break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -30264,9 +30290,9 @@ var ts; } } break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -30282,7 +30308,7 @@ var ts; } break loop; } - if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -30290,7 +30316,7 @@ var ts; } } break; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* 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; @@ -30312,7 +30338,7 @@ var ts; // case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* 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); @@ -30325,14 +30351,14 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -30367,8 +30393,8 @@ var ts; location = location.parent; } break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -30387,7 +30413,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -30461,7 +30487,7 @@ 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 === 242 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 245 /* 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 } } @@ -30470,12 +30496,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 239 /* ModuleDeclaration */: // For `namespace N { N; }` + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -30543,9 +30569,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -30609,18 +30635,26 @@ 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 === 238 /* EnumDeclaration */) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32 /* Class */) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256 /* RegularEnum */) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -30633,13 +30667,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 245 /* ImportClause */: + case 248 /* ImportClause */: return node.parent; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return node.parent.parent; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -30649,7 +30683,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -30837,20 +30871,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 249 /* ExportAssignment */: - case 200 /* BinaryExpression */: + case 252 /* ExportAssignment */: + case 202 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -30911,11 +30945,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 252 /* ExportSpecifier */) { + else if (node.kind === 255 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -30943,7 +30977,7 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -30967,7 +31001,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -31132,10 +31166,19 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages( - /*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)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages( + /*details*/ undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : 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)) + : undefined; 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)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -31161,7 +31204,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -31394,6 +31437,12 @@ var ts; var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -31412,25 +31461,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -31446,12 +31489,12 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -31548,7 +31591,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, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -31660,10 +31703,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -31716,8 +31759,8 @@ var ts; // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || - entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || + entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -31799,64 +31842,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; // TODO: GH#18217 + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -31864,6 +31876,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -31981,7 +31995,7 @@ var ts; 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 & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -32050,7 +32064,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 === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -32088,7 +32102,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; + return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -32136,8 +32150,15 @@ var ts; } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -32351,7 +32372,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 === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -32405,7 +32426,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -32413,7 +32434,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); 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 isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -32422,7 +32443,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; + var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -32432,7 +32454,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 === 182 /* BindingElement */) { + if (clone.kind === 184 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -32516,17 +32538,49 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + 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, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= 16777216 /* InInitialEntityName */; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216 /* InInitialEntityName */; var isTypeOf = meaning === 67216319 /* Value */; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -32700,8 +32754,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 !== 173 /* ParenthesizedType */; }); - if (node.kind === 237 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); + if (node.kind === 240 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -32709,11 +32763,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 /* ModuleBlock */ && + node.parent.kind === 243 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -32733,42 +32787,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 - var file = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); - if (!file || !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); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205 /* ClassExpression */: - return "(Anonymous class)"; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - return "(Anonymous function)"; + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + context.encounteredError = true; + } + return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -32793,27 +32827,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* 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 182 /* BindingElement */: + case 184 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 232 /* VariableDeclaration */: + case 235 /* 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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 234 /* FunctionDeclaration */: - case 238 /* EnumDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 241 /* EnumDeclaration */: + case 246 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -32821,7 +32855,7 @@ 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 !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -32843,31 +32877,31 @@ var ts; case 158 /* CallSignature */: case 160 /* IndexSignature */: case 149 /* Parameter */: - case 240 /* ModuleBlock */: + case 243 /* 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 */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 175 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: return false; // Type parameters are always visible case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 274 /* SourceFile */: - case 242 /* NamespaceExportDeclaration */: + case 277 /* SourceFile */: + case 245 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return false; default: return false; @@ -32876,10 +32910,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 252 /* ExportSpecifier */) { + else if (node.parent.kind === 255 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -32975,12 +33009,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232 /* VariableDeclaration */: - case 233 /* VariableDeclarationList */: - case 248 /* ImportSpecifier */: - case 247 /* NamedImports */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 235 /* VariableDeclaration */: + case 236 /* VariableDeclarationList */: + case 251 /* ImportSpecifier */: + case 250 /* NamedImports */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: return false; default: return true; @@ -33057,7 +33091,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180 /* ObjectBindingPattern */) { + if (pattern.kind === 182 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -33127,22 +33161,27 @@ var ts; // 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(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); + // If the parent is a tuple type, the rest element has an array type with a union of the + // remaining tuple element types. Otherwise, the rest element has an array type with same + // element type as the parent type. + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -33153,7 +33192,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2 /* Subtype */) : type; } @@ -33170,7 +33209,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -33180,11 +33219,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 === 221 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* 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, @@ -33203,7 +33242,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 /* 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 @@ -33275,20 +33314,20 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : - declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : 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 === 155 /* Constructor */ || - thisContainer.kind === 234 /* FunctionDeclaration */ || - (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 /* FunctionDeclaration */ || + (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -33309,7 +33348,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { // If we don't have an explicit JSDoc type, get the type from the expression. var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 /* Anonymous */ && @@ -33391,7 +33430,7 @@ var ts; // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -33436,12 +33475,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { 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. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -33458,7 +33498,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 /* ObjectBindingPattern */ + return pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -33527,7 +33567,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 === 249 /* ExportAssignment */) { + if (declaration.kind === 252 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -33731,8 +33771,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 202 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 187 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 202 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -33869,35 +33909,35 @@ var ts; return undefined; } switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 153 /* MethodSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 177 /* MappedType */: - case 171 /* ConditionalType */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 179 /* MappedType */: + case 173 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177 /* MappedType */) { + if (node.kind === 179 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171 /* ConditionalType */) { + else if (node.kind === 173 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && + (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -33905,7 +33945,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, 236 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -33914,9 +33954,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 235 /* ClassDeclaration */ || - node.kind === 205 /* ClassExpression */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || + node.kind === 207 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -33950,15 +33990,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - // Prefer an @augments tag because it may have type parameters. - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -33981,7 +34013,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -34014,7 +34046,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { if (type.symbol.flags & 32 /* Class */) { @@ -34077,7 +34109,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; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -34102,7 +34134,7 @@ var ts; 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 === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -34138,7 +34170,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */) { + if (declaration.kind === 239 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -34196,7 +34228,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -34223,7 +34255,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 200 /* BinaryExpression */) { + else if (expr.kind === 202 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -34237,12 +34269,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* 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 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -34256,7 +34288,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -34283,7 +34315,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 @@ -34373,7 +34405,7 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 178 /* LiteralType */: + case 180 /* LiteralType */: return true; case 167 /* ArrayType */: return isThislessType(node.elementType); @@ -34753,6 +34785,28 @@ var ts; return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 /* RestParameter */ : + i >= minLength_1 ? 4096 /* OptionalParameter */ : 0; + var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); @@ -34930,6 +34984,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); @@ -34938,6 +34993,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); @@ -35096,7 +35152,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 175 /* TypeOperator */ && + return constraintDeclaration.kind === 177 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -35216,6 +35272,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144 /* Union */)) { @@ -35673,10 +35740,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 === 283 /* JSDocOptionalType */ + node.type && node.type.kind === 286 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -35695,7 +35762,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -35710,7 +35777,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -35805,7 +35872,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178 /* LiteralType */) { + if (type && type.kind === 180 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -35853,9 +35920,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 8192 /* RestParameter */); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { // Replace the last parameter with a rest parameter. parameters.pop(); @@ -35961,9 +36027,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -36006,16 +36072,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1 /* Number */) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -36117,32 +36180,40 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - // When an 'infer T' declaration is immediately contained in a type reference node - // (such as 'Foo'), T's constraint is inferred from the constraint of the - // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are - // present, we form an intersection of the inferred constraint types. - if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - // Type parameter constraints can reference other type parameters so - // constraints need to be instantiated. If instantiation produces the - // type parameter itself, we discard that inference. For example, in - // type Foo = [T, U]; - // type Bar = T extends Foo ? Foo : T; - // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174 /* InferType */) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162 /* TypeReference */) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + // When an 'infer T' declaration is immediately contained in a rest parameter + // declaration, we infer an 'unknown[]' constraint. + else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -36237,7 +36308,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 !== 290 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 293 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -36296,7 +36367,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -36389,9 +36460,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -36503,9 +36574,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return declaration; } } @@ -36626,18 +36697,26 @@ var ts; // // Note that the generic type created by this function has no symbol associated with it. The same // is true for each of the synthesized type parameters. - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536 /* TypeParameter */); - typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + if (i < maxLength) { + var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4 /* Property */, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; @@ -36655,21 +36734,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -37063,7 +37168,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -37128,7 +37233,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -37148,6 +37253,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { @@ -37158,7 +37269,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* 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))) { @@ -37175,14 +37286,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* 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)); } @@ -37288,7 +37407,7 @@ 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 === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -37428,7 +37547,7 @@ var ts; return true; } while (node) { - if (node.kind === 171 /* ConditionalType */) { + if (node.kind === 173 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -37526,7 +37645,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } 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); + var errorMessage = 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_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -37732,7 +37854,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -37751,8 +37873,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return anyType; case 142 /* UnknownKeyword */: return unknownType; @@ -37774,16 +37896,16 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 162 /* TypeReference */: return getTypeFromTypeReference(node); case 161 /* TypePredicate */: return booleanType; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); @@ -37791,38 +37913,41 @@ var ts; return getTypeFromArrayTypeNode(node); case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return getTypeFromOptionalTypeNode(node); + case 171 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 173 /* ParenthesizedType */: - case 282 /* JSDocNonNullableType */: - case 278 /* JSDocTypeExpression */: + case 175 /* ParenthesizedType */: + case 170 /* RestType */: + case 285 /* JSDocNonNullableType */: + case 281 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 172 /* InferType */: + case 174 /* InferType */: return getTypeFromInferTypeNode(node); - case 179 /* ImportType */: + case 181 /* 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 @@ -37971,7 +38096,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | (ts.getCheckFlags(symbol) & 1024 /* Late */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (1024 /* Late */ | 4096 /* OptionalParameter */ | 8192 /* RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -37982,11 +38107,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -38051,14 +38171,14 @@ 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 === 213 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -38196,32 +38316,32 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive); - case 262 /* JsxAttribute */: { + case 265 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265 /* JsxExpression */: { + case 268 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -38238,7 +38358,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* 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); @@ -38248,7 +38368,7 @@ var ts; } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 213 /* Block */ ? false : isContextSensitive(body); + return body.kind === 216 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -38318,8 +38438,206 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268 /* JsxExpression */: + case 193 /* ParenthesizedExpression */: + return elaborateError(node.expression, source, target); + case 202 /* BinaryExpression */: + switch (node.operatorToken.kind) { + case 58 /* EqualsToken */: + case 26 /* CommaToken */: + return elaborateError(node.right, source, target); + } + break; + case 186 /* ObjectLiteralExpression */: + return elaborateObjectLiteral(node, source, target); + case 185 /* ArrayLiteralExpression */: + return elaborateArrayLiteral(node, source, target); + case 266 /* JsxAttributes */: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator, source, target) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + var resultObj = {}; + // Use the expression type, if available + var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + getIndexInfoOfType(target, 0 /* String */) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3 /*break*/, 3]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2 /*return*/]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3 /*break*/, 4]; + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3 /*break*/, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3 /*break*/, 3]; + nameType = getLiteralType(i); + return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3 /*break*/, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 32768 /* Never */)) { + return [3 /*break*/, 7]; + } + _b = prop.kind; + switch (_b) { + case 157 /* SetAccessor */: return [3 /*break*/, 2]; + case 156 /* GetAccessor */: return [3 /*break*/, 2]; + case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + } + return [3 /*break*/, 6]; + case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3 /*break*/, 7]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3 /*break*/, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** * This is *not* a bi-directional relationship. @@ -38340,13 +38658,20 @@ var ts; if (source === target) { return -1 /* True */; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0 /* False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0 /* False */; + } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; @@ -38367,14 +38692,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -38393,7 +38715,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0 /* False */; } @@ -38468,30 +38790,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - // If both have rest parameters, get the max and add 1 to - // compensate for the rest parameter. - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - // Return the count for whichever signature doesn't have rest parameters. - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -38512,11 +38810,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { + return relation === 1 /* Succeeded */; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, false); + enumRelation.set(id, 3 /* FailedAndReported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -38527,13 +38825,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); + enumRelation.set(id, 3 /* FailedAndReported */); + } + else { + enumRelation.set(id, 2 /* Failed */); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1 /* Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -38624,7 +38925,7 @@ var ts; * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -38654,12 +38955,16 @@ var ts; var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); // Cause the error to appear with the error that triggered it + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); // Cause the error to appear with the error that triggered it } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); // TODO: GH#18217 + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { @@ -38741,6 +39046,22 @@ var ts; if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); + if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + target = nullStrippedTarget; + } + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; @@ -38992,11 +39313,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } return 0 /* False */; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072 /* Object */) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4 /* Reference */) { + return source.target === target.target; + } + if (overlapObjFlags & 16 /* Anonymous */) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { var match; @@ -39128,9 +39467,8 @@ var ts; var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2 /* Failed */) { - // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported - // failure and continue computing the relation such that errors get reported. - relation.set(id, 3 /* FailedAndReported */); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -39417,7 +39755,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -39440,6 +39778,33 @@ var ts; } } var result = -1 /* True */; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0 /* False */; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0 /* False */; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0 /* False */; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -39961,20 +40326,26 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); // A source signature matches a target signature if the two signatures have the same number of required, // optional, and rest parameters. - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } // A source signature partially matches a target signature if the target signature has no fewer required // parameters and no more overall parameters than the source signature (where a signature with a rest // parameter is always considered to have more overall parameters than one without). - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -40016,10 +40387,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0 /* False */; @@ -40039,9 +40410,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -40091,7 +40459,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); @@ -40138,6 +40511,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -40197,7 +40576,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -40410,7 +40789,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -40420,23 +40799,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* 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 177 /* MappedType */: + case 179 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -40453,24 +40832,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -40609,10 +40986,14 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - // Two tuple types with different arity are definitely unrelated. + // Two tuple types with incompatible arities are definitely unrelated. // Two object types that each have a property that is unmatched in the other are definitely unrelated. - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) && !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false); } function getTypeFromInference(inference) { @@ -40895,12 +41276,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -41015,17 +41417,14 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + // If we have contravariant inferences we find the best common subtype and treat + // that as a single covariant candidate. + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { 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 & 32768 /* Never */ && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - // We only have contravariant inferences, infer the best common subtype of those - inferredType = getContravariantInference(inference); } else if (context.flags & 2 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -41102,13 +41501,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 185 /* PropertyAccessExpression */) { + if (node.kind === 187 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182 /* BindingElement */) { + if (node.kind === 184 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -41117,7 +41516,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180 /* ObjectBindingPattern */) { + if (parent.kind === 182 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: @@ -41140,26 +41539,26 @@ var ts; switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && + (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 185 /* PropertyAccessExpression */: - return target.kind === 185 /* PropertyAccessExpression */ && + case 187 /* PropertyAccessExpression */: + return target.kind === 187 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182 /* BindingElement */: - if (target.kind !== 185 /* PropertyAccessExpression */) + case 184 /* BindingElement */: + if (target.kind !== 187 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232 /* VariableDeclaration */) { + if (source.parent.parent.kind === 235 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -41167,7 +41566,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185 /* PropertyAccessExpression */) { + while (source.kind === 187 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -41180,7 +41579,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 === 185 /* PropertyAccessExpression */ && + return target.kind === 187 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -41188,7 +41587,7 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185 /* PropertyAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -41232,7 +41631,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -41358,7 +41757,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; } @@ -41366,15 +41765,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -41391,21 +41790,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return stringType; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return undefinedType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -41413,7 +41812,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 /* ObjectBindingPattern */ ? + var type = pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -41431,35 +41830,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221 /* ForInStatement */) { + if (node.parent.parent.kind === 224 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.parent.kind === 225 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 /* VariableDeclaration */ ? + return node.kind === 235 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? + return node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 /* VariableDeclaration */ && node.initializer && + return node.kind === 235 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && + node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -41471,13 +41870,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - 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 ? + return parent.kind === 193 /* ParenthesizedExpression */ || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -41640,11 +42039,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - 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 */ && + var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 200 /* BinaryExpression */ && + parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -41692,7 +42091,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 === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -41763,7 +42162,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 !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 187 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -41819,7 +42218,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 /* CallExpression */ ? + var expr = node.kind === 189 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -41827,7 +42226,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -41992,7 +42391,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 /* PropertyAccessExpression */ && + return expr.kind === 187 /* PropertyAccessExpression */ && computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -42043,10 +42442,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 === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -42261,7 +42660,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -42281,15 +42680,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -42325,8 +42724,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 /* ModuleBlock */ || - node.kind === 274 /* SourceFile */ || + node.kind === 243 /* ModuleBlock */ || + node.kind === 277 /* SourceFile */ || node.kind === 152 /* PropertyDeclaration */; }); } @@ -42372,10 +42771,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - 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; + return parent.kind === 187 /* PropertyAccessExpression */ || + parent.kind === 189 /* CallExpression */ && parent.expression === node || + parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); @@ -42409,7 +42808,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 */)) { @@ -42430,7 +42829,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 === 235 /* ClassDeclaration */ + if (declaration.kind === 238 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -42442,12 +42841,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205 /* ClassExpression */) { + else if (declaration.kind === 207 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 274 /* SourceFile */) { + while (container.kind !== 277 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; @@ -42497,23 +42896,23 @@ var ts; 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); + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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 === 192 /* FunctionExpression */ || - flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 /* FunctionExpression */ || + flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // 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 || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || 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 || + isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || + node.parent.kind === 211 /* NonNullExpression */ || + declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -42544,7 +42943,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -42569,8 +42968,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 === 220 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && + if (container.kind === 223 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -42584,7 +42983,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 191 /* ParenthesizedExpression */) { + while (current.parent.kind === 193 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -42592,7 +42991,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -42650,7 +43049,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); // If a containing class does not have extends clause or the class extends null // skip checking whether super statement is called before "this" accessing. if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -42677,17 +43076,17 @@ var ts; 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 === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 238 /* EnumDeclaration */: + case 241 /* 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; @@ -42725,8 +43124,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 === 192 /* FunctionExpression */ && - container.parent.kind === 200 /* BinaryExpression */ && + if (container.kind === 194 /* FunctionExpression */ && + container.parent.kind === 202 /* 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 @@ -42757,7 +43156,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -42774,12 +43173,12 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 /* 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 === 193 /* ArrowFunction */) { + while (container && container.kind === 195 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -42799,7 +43198,7 @@ var ts; 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 === 184 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -42887,7 +43286,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184 /* ObjectLiteralExpression */) { + if (container.parent.kind === 186 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -42899,7 +43298,7 @@ var ts; } // at this point the only legal case for parent is ClassLikeDeclaration var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -42931,7 +43330,7 @@ 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 === 184 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 154 /* MethodDeclaration */ || container.kind === 153 /* MethodSignature */ || @@ -42955,8 +43354,8 @@ var ts; function getContainingObjectLiteral(func) { 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 : + func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -42968,7 +43367,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193 /* ArrowFunction */) { + if (func.kind === 195 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -42995,7 +43394,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270 /* PropertyAssignment */) { + if (literal.parent.kind !== 273 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -43009,9 +43408,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 === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { + if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* 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)) { @@ -43034,27 +43433,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. @@ -43064,10 +43460,8 @@ var ts; return getTypeAtPosition(contextualSignature, indexOfParameter); } // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -43098,7 +43492,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182 /* BindingElement */) { + if (parentDeclaration.kind !== 184 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -43180,7 +43574,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189 /* TaggedTemplateExpression */) { + if (template.parent.kind === 191 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -43228,8 +43622,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504 /* StructuredType */) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, /*noReductions*/ true); } function getIndexTypeOfContextualType(type, kind) { @@ -43258,8 +43663,8 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -43325,8 +43730,8 @@ var ts; case 95 /* NullKeyword */: case 71 /* Identifier */: return true; - case 185 /* PropertyAccessExpression */: - case 191 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 193 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -43345,14 +43750,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270 /* PropertyAssignment */) + if (prop.kind !== 273 /* PropertyAssignment */) continue; 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); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine @@ -43393,52 +43798,52 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 193 /* ArrowFunction */: - case 225 /* ReturnStatement */: + case 195 /* ArrowFunction */: + case 228 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 183 /* ArrayLiteralExpression */: { + case 185 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 211 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); + case 214 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191 /* ParenthesizedExpression */: { + case 193 /* 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 265 /* JsxExpression */: + case 268 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -43512,6 +43917,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -43522,8 +43928,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) @@ -43539,7 +43961,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -43584,11 +44007,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; + return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -43660,18 +44082,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 182 /* BindingElement */ && !!node.initializer) || - (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 184 /* BindingElement */ && !!node.initializer) || + (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -43696,13 +44119,17 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; + if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } @@ -43710,28 +44137,30 @@ 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 === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - 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); + else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { + if (e.kind !== 208 /* OmittedExpression */) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2 /* Subtype */); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2 /* Subtype */) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -43816,7 +44245,7 @@ var ts; var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -43830,11 +44259,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 /* PropertyAssignment */ || - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 273 /* PropertyAssignment */ || + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -43855,8 +44284,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 === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -43881,7 +44310,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272 /* SpreadAssignment */) { + else if (memberDecl.kind === 275 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -43975,13 +44404,16 @@ var ts; type.flags & 131072 /* Object */ && !isGenericMappedType(type) || type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { + function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -43989,6 +44421,9 @@ var ts; else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -44011,16 +44446,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - // TODO (yuisu): comment - switch (tagName.kind) { - case 185 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: - return false; - case 71 /* Identifier */: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -44063,7 +44489,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -44086,7 +44512,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 255 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 /* 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); @@ -44247,12 +44673,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -44289,6 +44727,10 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928 /* Type */); + } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -44695,7 +45137,7 @@ var ts; // sourceAttributesType is a type of an attributes properties. // i.e
// attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. @@ -44716,31 +45158,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -44787,9 +45205,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? + var errorNode = node.kind === 187 /* PropertyAccessExpression */ || node.kind === 235 /* VariableDeclaration */ ? node.name : - node.kind === 179 /* ImportType */ ? + node.kind === 181 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -44959,7 +45377,7 @@ 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 !== 185 /* PropertyAccessExpression */ || + if (node.kind !== 187 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; @@ -44991,16 +45409,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + else if (valueDeclaration.kind === 238 /* 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)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -45008,7 +45431,7 @@ var ts; switch (node.kind) { case 152 /* PropertyDeclaration */: return true; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -45064,13 +45487,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319 /* Value */); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319 /* Value */); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -45129,16 +45558,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179 /* ImportType */: + case 181 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -45172,7 +45601,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer.kind === 236 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -45201,7 +45630,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 /* ForInStatement */ && + if (node.kind === 224 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -45219,7 +45648,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 190 /* 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); @@ -45286,7 +45715,7 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (node.kind !== 150 /* Decorator */) { @@ -45352,14 +45781,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204 /* SpreadElement */) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -45371,12 +45797,12 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* 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 = node.typeArguments; - if (node.template.kind === 202 /* TemplateExpression */) { + if (node.template.kind === 204 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -45398,8 +45824,8 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 188 /* NewExpression */); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190 /* NewExpression */); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. @@ -45412,15 +45838,14 @@ var ts; } // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -45445,9 +45870,10 @@ var ts; // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1 /* InferUnionTypes */, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8 /* ReturnType */); @@ -45497,7 +45923,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -45512,11 +45938,13 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; 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 !== 206 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -45530,6 +45958,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) @@ -45547,6 +45979,35 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + // We are inferring from a spread expression in the last argument position, i.e. both the parameter + // and the argument are ...x forms. + return arg.kind === 213 /* SyntheticExpression */ ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -45606,7 +46067,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 190 /* 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. @@ -45620,24 +46081,32 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; 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 !== 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. - // In that case, we should check the argument. - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { + if (i === restIndex && (restType.flags & 65536 /* TypeParameter */ || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, /*context*/ undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + // 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. + // In that case, we should check the argument. + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } @@ -45647,9 +46116,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { + if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { return callee.expression; } } @@ -45664,10 +46133,10 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [undefined]; // TODO: GH#18217 - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -45684,7 +46153,28 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + // We have a spread argument in the last position and no other spread arguments. If the type + // of the argument is a tuple type, spread the tuple elements into the argument list. We can + // call checkExpressionCached because spread expressions never have a contextual type. + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213 /* SyntheticExpression */, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } /** @@ -45703,8 +46193,8 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; case 152 /* PropertyDeclaration */: @@ -45749,7 +46239,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* 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); @@ -45794,7 +46284,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -45849,7 +46339,7 @@ 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 === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -45898,7 +46388,7 @@ var ts; if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -45911,7 +46401,7 @@ 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 === 150 /* Decorator */ || - (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { + (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -45924,7 +46414,7 @@ var ts; // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -45944,7 +46434,7 @@ 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 === 189 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -46019,7 +46509,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 === 187 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 /* 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 @@ -46066,10 +46556,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -46184,11 +46674,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -46204,7 +46695,7 @@ var ts; 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)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -46383,8 +46874,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -46410,8 +46900,8 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -46487,16 +46977,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -46572,7 +47062,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -46586,7 +47077,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185 /* PropertyAccessExpression */) { + while (parent && parent.kind === 187 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -46618,7 +47109,7 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 188 /* NewExpression */) { + if (node.kind === 190 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 /* Constructor */ && @@ -46692,7 +47183,7 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -46749,9 +47240,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 234 /* FunctionDeclaration */ + ? 237 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 232 /* VariableDeclaration */ + ? 235 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -46829,10 +47320,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1 /* Number */) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536 /* TypeParameter */) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -46871,11 +47459,11 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -46940,7 +47528,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213 /* Block */) { + if (func.body.kind !== 216 /* 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 @@ -47029,7 +47617,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -47054,7 +47642,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -47097,11 +47685,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; case 154 /* MethodDeclaration */: - return func.parent.kind === 184 /* ObjectLiteralExpression */; + return func.parent.kind === 186 /* ObjectLiteralExpression */; default: return false; } @@ -47125,7 +47713,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -47165,7 +47753,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -47226,7 +47814,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213 /* Block */) { + if (node.body.kind === 216 /* Block */) { checkSourceElement(node.body); } else { @@ -47239,10 +47827,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -47272,7 +47860,7 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && + (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* 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); @@ -47289,13 +47877,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* 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 === 246 /* NamespaceImport */; + return !!declaration && declaration.kind === 249 /* NamespaceImport */; } } } @@ -47304,7 +47892,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 !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -47313,7 +47901,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { + if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -47490,7 +48078,7 @@ 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 === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { var name = property.name; if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); @@ -47505,7 +48093,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 274 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -47517,7 +48105,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 === 272 /* SpreadAssignment */) { + else if (property.kind === 275 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -47552,27 +48140,23 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206 /* OmittedExpression */) { - if (element.kind !== 204 /* SpreadElement */) { + if (element.kind !== 208 /* OmittedExpression */) { + if (element.kind !== 206 /* SpreadElement */) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - // We still need to check element expression here because we may need to set appropriate flag on the expression - // such as NodeCheckFlags.LexicalThis on "this"expression. - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -47581,12 +48165,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -47595,7 +48182,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -47611,25 +48198,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184 /* ObjectLiteralExpression */) { + if (target.kind === 186 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183 /* ArrayLiteralExpression */) { + if (target.kind === 185 /* 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 === 272 /* SpreadAssignment */ ? + var error = target.parent.kind === 275 /* 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)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -47647,35 +48234,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 189 /* TaggedTemplateExpression */: - case 202 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - 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 */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 197 /* TypeOfExpression */: + case 211 /* NonNullExpression */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: return true; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -47687,9 +48274,9 @@ var ts; } return false; // Some forms listed here for clarity - 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 + case 198 /* VoidExpression */: // Explicit opt-out + case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -47705,7 +48292,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -47904,7 +48491,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -47925,7 +48512,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34 /* EqualsEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -47982,7 +48585,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' return anyType; @@ -48007,7 +48610,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263 /* JsxAttributes */) { + if (node.kind === 266 /* 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; @@ -48043,7 +48646,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; + return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -48145,7 +48748,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 === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 /* 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) { @@ -48195,8 +48798,8 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 188 /* 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) { @@ -48232,74 +48835,76 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checkCallExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return checkClassExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return checkAssertion(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return checkNonNullAssertion(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return checkMetaProperty(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkDeleteExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return checkVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return checkAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return undefinedWideningType; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return checkYieldExpression(node); - case 265 /* JsxExpression */: + case 213 /* SyntheticExpression */: + return node.type; + case 268 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return checkJsxElement(node, checkMode); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -48328,6 +48933,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 /* Instantiable */ && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -48354,7 +48962,7 @@ var ts; } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -48415,10 +49023,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 158 /* CallSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 163 /* FunctionType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -48439,7 +49047,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 === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { + else if (name.kind === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -48452,7 +49060,7 @@ var ts; checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + else if (node.kind === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -48517,7 +49125,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -48646,7 +49254,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* 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 @@ -48734,7 +49342,7 @@ var ts; // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -48756,7 +49364,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 === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -48907,11 +49515,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170 /* RestType */) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169 /* OptionalType */) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -48925,7 +49550,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 186 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 /* 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)); } @@ -48962,7 +49587,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* 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); @@ -48978,9 +49603,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 !== 236 /* InterfaceDeclaration */ && - n.parent.kind !== 235 /* ClassDeclaration */ && - n.parent.kind !== 205 /* ClassExpression */ && + if (n.parent.kind !== 239 /* InterfaceDeclaration */ && + n.parent.kind !== 238 /* ClassDeclaration */ && + n.parent.kind !== 207 /* 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 @@ -49110,7 +49735,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 /* 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 @@ -49121,7 +49746,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 === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -49250,22 +49875,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 249 /* ExportAssignment */: + case 252 /* 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 */; @@ -49273,17 +49898,17 @@ 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 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 248 /* 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 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 234 /* FunctionDeclaration */: - case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 237 /* FunctionDeclaration */: + case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -49554,7 +50179,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -49617,12 +50242,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -49654,7 +50279,7 @@ var ts; } } return commonEntityName; - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); case 162 /* TypeReference */: return node.typeName; @@ -49687,7 +50312,7 @@ var ts; 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -49776,7 +50401,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -49788,7 +50413,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -49871,27 +50496,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274 /* SourceFile */: - case 239 /* ModuleDeclaration */: - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 242 /* ModuleDeclaration */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -49905,7 +50530,7 @@ var ts; case 159 /* ConstructSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -49918,10 +50543,7 @@ var ts; 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.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -49951,7 +50573,7 @@ var ts; } break; case 160 /* IndexSignature */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: // Can't be private break; default: @@ -49967,7 +50589,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -50002,7 +50624,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -50020,9 +50642,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -50037,7 +50659,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0 /* Local */, unuseds.length === 1 @@ -50055,7 +50677,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -50076,7 +50698,7 @@ var ts; 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)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -50090,22 +50712,22 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; + return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 213 /* Block */) { + if (node.kind === 216 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -50200,7 +50822,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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 /* 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)); } @@ -50215,7 +50837,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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 277 /* 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)); } @@ -50250,7 +50872,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 === 232 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -50262,17 +50884,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 214 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 217 /* 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 === 213 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 240 /* ModuleBlock */ || - container.kind === 239 /* ModuleDeclaration */ || - container.kind === 274 /* SourceFile */); + (container.kind === 216 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 243 /* ModuleBlock */ || + container.kind === 242 /* ModuleDeclaration */ || + container.kind === 277 /* 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 @@ -50298,7 +50920,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 185 /* PropertyAccessExpression */) { + if (n.kind === 187 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -50318,7 +50940,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 182 /* BindingElement */) { + symbol.valueDeclaration.kind === 184 /* 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) { @@ -50371,8 +50993,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182 /* BindingElement */) { - if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 184 /* BindingElement */) { + if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -50393,7 +51015,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -50406,13 +51028,13 @@ var ts; // 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 !== 221 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -50429,8 +51051,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221 /* ForInStatement */) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -50445,7 +51067,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -50455,7 +51077,7 @@ var ts; 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 === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -50470,8 +51092,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || - (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || + (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -50510,7 +51132,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215 /* EmptyStatement */) { + if (node.thenStatement.kind === 218 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -50530,12 +51152,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -50569,14 +51191,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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. @@ -50590,7 +51212,7 @@ var ts; // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -50608,7 +51230,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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); @@ -50622,7 +51244,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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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)) { @@ -50986,7 +51608,7 @@ var ts; } } else if (func.kind === 155 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -51002,7 +51624,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -51035,7 +51657,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 === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -51047,7 +51669,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 269 /* 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. @@ -51076,7 +51698,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -51174,16 +51796,17 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } // perform property check if property or indexer is declared in 'type' // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || + if (propDeclaration && name && + (propDeclaration.kind === 202 /* BinaryExpression */ || + name.kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -51357,7 +51980,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); @@ -51369,6 +51992,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -51435,7 +52062,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -51454,7 +52081,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -51480,7 +52107,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; + return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -51519,7 +52146,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 === 205 /* ClassExpression */) { + if (derivedClassDecl.kind === 207 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -51633,7 +52260,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -51696,7 +52323,7 @@ var ts; } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -51711,7 +52338,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -51738,7 +52365,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -51748,7 +52375,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -51776,7 +52403,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: var identifier = expr; @@ -51784,14 +52411,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* 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 === 185 /* PropertyAccessExpression */) { + if (ex.kind === 187 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -51823,8 +52450,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -51838,7 +52465,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304 /* Ambient */) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -51854,7 +52481,7 @@ var ts; if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -51862,7 +52489,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 !== 238 /* EnumDeclaration */) { + if (declaration.kind !== 241 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -51885,8 +52512,8 @@ var ts; var declarations = symbol.declarations; 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))) && + if ((declaration.kind === 238 /* ClassDeclaration */ || + (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -51949,7 +52576,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, 235 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -51999,23 +52626,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* 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 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -52026,12 +52653,12 @@ var ts; break; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 234 /* FunctionDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -52059,7 +52686,7 @@ var ts; node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -52076,9 +52703,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - 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 */ ? + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -52111,14 +52738,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 === 252 /* ExportSpecifier */ ? + var message = node.kind === 255 /* 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 === 252 /* ExportSpecifier */ + && node.kind === 255 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -52145,7 +52772,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -52169,7 +52796,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -52205,10 +52832,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -52225,7 +52852,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -52254,8 +52881,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 === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -52343,7 +52970,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -52361,10 +52988,10 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -52402,111 +53029,113 @@ var ts; return checkArrayType(node); case 168 /* TupleType */: return checkTupleType(node); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: + case 169 /* OptionalType */: + case 170 /* RestType */: return checkSourceElement(node.type); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return checkTypeOperator(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return checkConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return checkInferType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return checkImportType(node); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 282 /* JSDocNonNullableType */: - case 281 /* JSDocNullableType */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: - case 287 /* JSDocTypeLiteral */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: + case 290 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 278 /* JSDocTypeExpression */: + case 281 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return checkMappedType(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return checkBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return checkVariableStatement(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return checkExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return checkIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return checkDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return checkWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return checkForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return checkForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkForOfStatement(node); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return checkReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return checkSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return checkLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return checkThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return checkTryStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return checkBindingElement(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return checkClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return checkImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return checkExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return checkExportAssignment(node); - case 215 /* EmptyStatement */: - case 231 /* DebuggerStatement */: + case 218 /* EmptyStatement */: + case 234 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -52583,15 +53212,15 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -52600,11 +53229,17 @@ var ts; case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: checkClassExpressionDeferred(node); break; + case 259 /* JsxSelfClosingElement */: + checkJsxSelfClosingElementDeferred(node); + break; + case 258 /* JsxElement */: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -52639,7 +53274,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -52733,13 +53368,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -52747,8 +53382,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* 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. @@ -52757,7 +53392,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -52806,10 +53441,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148 /* TypeParameter */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -52823,10 +53458,10 @@ var ts; return node.parent.kind === 162 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185 /* PropertyAccessExpression */) { + while (node.parent.kind === 187 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 207 /* ExpressionWithTypeArguments */; + return node.parent.kind === 209 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -52857,10 +53492,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -52886,7 +53521,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -52896,7 +53531,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 /* PropertyAccessExpression */ && + entityName.parent.kind === 187 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -52904,7 +53539,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 /* 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); @@ -52914,7 +53549,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, 243 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -52932,7 +53567,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 === 207 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -52948,10 +53583,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293 /* JSDocParameterTag */) { + if (entityName.parent.kind === 296 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 297 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 300 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -52968,12 +53603,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185 /* PropertyAccessExpression */) { + if (entityName.kind === 187 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -52986,7 +53621,7 @@ var ts; var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 262 /* JsxAttribute */) { + else if (entityName.parent.kind === 265 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161 /* TypePredicate */) { @@ -52996,7 +53631,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -53016,8 +53651,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 /* BindingElement */ && - grandParent.kind === 180 /* ObjectBindingPattern */ && + else if (parent.kind === 184 /* BindingElement */ && + grandParent.kind === 182 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -53028,7 +53663,7 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: @@ -53043,7 +53678,7 @@ var ts; return checkExpression(node).symbol; } // falls through - case 174 /* ThisType */: + case 176 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; @@ -53061,7 +53696,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 === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* 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); @@ -53079,14 +53714,14 @@ var ts; case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -53159,28 +53794,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 222 /* ForOfStatement */) { + if (expr.parent.kind === 225 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 200 /* BinaryExpression */) { + if (expr.parent.kind === 202 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 270 /* PropertyAssignment */) { + if (expr.parent.kind === 273 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -53259,7 +53894,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -53315,7 +53950,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* 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. @@ -53370,7 +54005,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 === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -53411,16 +54046,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -53430,7 +54065,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -53511,22 +54146,23 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273 /* EnumMember */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 276 /* EnumMember */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273 /* EnumMember */) { + if (node.kind === 276 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8 /* EnumMember */)) { // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -53664,7 +54300,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } @@ -53761,7 +54397,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; + return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -53773,7 +54409,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 === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -53824,7 +54460,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -53839,12 +54475,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 /* 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, 274 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 277 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -53852,10 +54488,14 @@ var ts; var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); // Initialize global symbol table var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -53929,6 +54569,32 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -54022,7 +54688,7 @@ var ts; } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { + if (node.kind !== 241 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -54042,7 +54708,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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -54065,7 +54731,7 @@ 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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149 /* Parameter */) { @@ -54101,7 +54767,7 @@ 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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149 /* Parameter */) { @@ -54110,8 +54776,8 @@ var ts; flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -54123,13 +54789,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } 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 === 240 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -54139,14 +54805,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 238 /* 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 === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 238 /* 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 */) { @@ -54188,7 +54854,7 @@ var ts; } return false; } - else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -54223,29 +54889,29 @@ var ts; 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 242 /* ModuleDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 149 /* Parameter */: return false; default: - if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return false; } switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 236 /* InterfaceDeclaration */: - case 214 /* VariableStatement */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 217 /* VariableStatement */: + case 240 /* TypeAliasDeclaration */: return true; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -54259,9 +54925,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -54394,7 +55060,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206 /* OmittedExpression */) { + if (arg.kind === 208 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -54475,15 +55141,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 202 /* 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 === 234 /* FunctionDeclaration */ || - node.kind === 192 /* FunctionExpression */ || + ts.Debug.assert(node.kind === 237 /* FunctionDeclaration */ || + node.kind === 194 /* FunctionExpression */ || node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -54507,7 +55173,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 === 272 /* SpreadAssignment */) { + if (prop.kind === 275 /* SpreadAssignment */) { continue; } var name = prop.name; @@ -54515,7 +55181,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 /* 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); @@ -54539,8 +55205,8 @@ 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 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -54590,7 +55256,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 === 264 /* JsxSpreadAttribute */) { + if (attr.kind === 267 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -54600,7 +55266,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -54609,12 +55275,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -54629,20 +55295,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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); @@ -54711,7 +55377,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* 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); @@ -54749,7 +55415,7 @@ var ts; return true; } if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 184 /* ObjectLiteralExpression */) { + if (node.parent.kind === 186 /* 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); @@ -54778,7 +55444,7 @@ var ts; 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 === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* 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 === 166 /* TypeLiteral */) { @@ -54792,11 +55458,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228 /* LabeledStatement */: + case 231 /* 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 === 223 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 226 /* 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); @@ -54804,8 +55470,8 @@ var ts; return false; } break; - case 227 /* SwitchStatement */: - if (node.kind === 224 /* BreakStatement */ && !node.label) { + case 230 /* SwitchStatement */: + if (node.kind === 227 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -54820,13 +55486,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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 === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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); @@ -54839,7 +55505,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 === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { + if (node.name.kind === 183 /* ArrayBindingPattern */ || node.name.kind === 182 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -54853,14 +55519,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { + if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -54871,7 +55537,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -54881,19 +55547,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 /* 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 && !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -54948,15 +55614,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return false; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -54966,7 +55632,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -55033,7 +55699,7 @@ var ts; return true; } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* 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; } @@ -55070,13 +55736,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - 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 */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 240 /* TypeAliasDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 253 /* ExportDeclaration */ || + node.kind === 252 /* ExportAssignment */ || + node.kind === 245 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -55085,7 +55751,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 214 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 217 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -55112,7 +55778,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 === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -55134,10 +55800,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, 178 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -55192,8 +55858,8 @@ var ts; /** 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 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -55201,14 +55867,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245 /* ImportClause */: // For default import - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: // For rename import `x as y` + case 248 /* ImportClause */: // For default import + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* 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 === 248 /* ImportSpecifier */; + return decl.parent.kind === 251 /* ImportSpecifier */; default: return false; } @@ -55224,8 +55890,12 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448 /* Literal */); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -55391,7 +56061,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 /* Node */ | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -55484,10 +56154,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 303 /* CommaListExpression */ ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147 /* ComputedPropertyName */); @@ -55850,14 +56519,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169 /* OptionalType */); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170 /* RestType */); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -55865,7 +56558,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -55884,7 +56577,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171 /* ConditionalType */); + var node = createSynthesizedNode(173 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -55902,7 +56595,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172 /* InferType */); + var node = createSynthesizedNode(174 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -55914,7 +56607,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179 /* ImportType */); + var node = createSynthesizedNode(181 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -55932,7 +56625,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173 /* ParenthesizedType */); + var node = createSynthesizedNode(175 /* ParenthesizedType */); node.type = type; return node; } @@ -55944,11 +56637,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174 /* ThisType */); + return createSynthesizedNode(176 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175 /* TypeOperator */); + var node = createSynthesizedNode(177 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -55959,7 +56652,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176 /* IndexedAccessType */); + var node = createSynthesizedNode(178 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -55973,7 +56666,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177 /* MappedType */); + var node = createSynthesizedNode(179 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -55991,7 +56684,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178 /* LiteralType */); + var node = createSynthesizedNode(180 /* LiteralType */); node.literal = literal; return node; } @@ -56004,7 +56697,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ObjectBindingPattern */); + var node = createSynthesizedNode(182 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56016,7 +56709,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181 /* ArrayBindingPattern */); + var node = createSynthesizedNode(183 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56028,7 +56721,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182 /* BindingElement */); + var node = createSynthesizedNode(184 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -56047,7 +56740,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -56061,7 +56754,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -56075,7 +56768,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185 /* PropertyAccessExpression */); + var node = createSynthesizedNode(187 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -56092,7 +56785,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186 /* ElementAccessExpression */); + var node = createSynthesizedNode(188 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -56106,7 +56799,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* CallExpression */); + var node = createSynthesizedNode(189 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -56122,7 +56815,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188 /* NewExpression */); + var node = createSynthesizedNode(190 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -56138,7 +56831,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -56161,7 +56854,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190 /* TypeAssertionExpression */); + var node = createSynthesizedNode(192 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -56175,7 +56868,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191 /* ParenthesizedExpression */); + var node = createSynthesizedNode(193 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -56187,7 +56880,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192 /* FunctionExpression */); + var node = createSynthesizedNode(194 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -56211,7 +56904,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193 /* ArrowFunction */); + var node = createSynthesizedNode(195 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -56245,7 +56938,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194 /* DeleteExpression */); + var node = createSynthesizedNode(196 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56257,7 +56950,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195 /* TypeOfExpression */); + var node = createSynthesizedNode(197 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56269,7 +56962,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196 /* VoidExpression */); + var node = createSynthesizedNode(198 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56281,7 +56974,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197 /* AwaitExpression */); + var node = createSynthesizedNode(199 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56293,7 +56986,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -56306,7 +56999,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -56319,7 +57012,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200 /* BinaryExpression */); + var node = createSynthesizedNode(202 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -56336,7 +57029,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201 /* ConditionalExpression */); + var node = createSynthesizedNode(203 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -56366,7 +57059,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202 /* TemplateExpression */); + var node = createSynthesizedNode(204 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -56404,7 +57097,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203 /* YieldExpression */); + var node = createSynthesizedNode(205 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -56418,7 +57111,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204 /* SpreadElement */); + var node = createSynthesizedNode(206 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -56430,7 +57123,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205 /* ClassExpression */); + var node = createSynthesizedNode(207 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56451,11 +57144,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206 /* OmittedExpression */); + return createSynthesizedNode(208 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -56469,7 +57162,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208 /* AsExpression */); + var node = createSynthesizedNode(210 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -56483,7 +57176,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209 /* NonNullExpression */); + var node = createSynthesizedNode(211 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -56495,7 +57188,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210 /* MetaProperty */); + var node = createSynthesizedNode(212 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -56509,7 +57202,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211 /* TemplateSpan */); + var node = createSynthesizedNode(214 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -56523,25 +57216,18 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212 /* SemicolonClassElement */); + return createSynthesizedNode(215 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213 /* Block */); + var block = createSynthesizedNode(216 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - /* @internal */ - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216 /* ExpressionStatement */); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -56549,7 +57235,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214 /* VariableStatement */); + var node = createSynthesizedNode(217 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -56564,21 +57250,27 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215 /* EmptyStatement */); + return createSynthesizedNode(218 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + ts.createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217 /* IfStatement */); + var node = createSynthesizedNode(220 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -56594,7 +57286,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218 /* DoStatement */); + var node = createSynthesizedNode(221 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -56608,7 +57300,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219 /* WhileStatement */); + var node = createSynthesizedNode(222 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -56622,7 +57314,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220 /* ForStatement */); + var node = createSynthesizedNode(223 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -56640,7 +57332,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForInStatement */); + var node = createSynthesizedNode(224 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -56656,7 +57348,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222 /* ForOfStatement */); + var node = createSynthesizedNode(225 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -56674,7 +57366,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223 /* ContinueStatement */); + var node = createSynthesizedNode(226 /* ContinueStatement */); node.label = asName(label); return node; } @@ -56686,7 +57378,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224 /* BreakStatement */); + var node = createSynthesizedNode(227 /* BreakStatement */); node.label = asName(label); return node; } @@ -56698,7 +57390,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225 /* ReturnStatement */); + var node = createSynthesizedNode(228 /* ReturnStatement */); node.expression = expression; return node; } @@ -56710,7 +57402,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226 /* WithStatement */); + var node = createSynthesizedNode(229 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -56724,7 +57416,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227 /* SwitchStatement */); + var node = createSynthesizedNode(230 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -56738,7 +57430,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228 /* LabeledStatement */); + var node = createSynthesizedNode(231 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -56752,7 +57444,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229 /* ThrowStatement */); + var node = createSynthesizedNode(232 /* ThrowStatement */); node.expression = expression; return node; } @@ -56764,7 +57456,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230 /* TryStatement */); + var node = createSynthesizedNode(233 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -56780,11 +57472,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231 /* DebuggerStatement */); + return createSynthesizedNode(234 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232 /* VariableDeclaration */); + var node = createSynthesizedNode(235 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -56801,7 +57493,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(233 /* VariableDeclarationList */); + var node = createSynthesizedNode(236 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -56814,7 +57506,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234 /* FunctionDeclaration */); + var node = createSynthesizedNode(237 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -56840,7 +57532,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* ClassDeclaration */); + var node = createSynthesizedNode(238 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56862,7 +57554,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236 /* InterfaceDeclaration */); + var node = createSynthesizedNode(239 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56884,7 +57576,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56904,7 +57596,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238 /* EnumDeclaration */); + var node = createSynthesizedNode(241 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56923,7 +57615,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* ModuleDeclaration */); + var node = createSynthesizedNode(242 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -56942,7 +57634,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240 /* ModuleBlock */); + var node = createSynthesizedNode(243 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -56954,7 +57646,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241 /* CaseBlock */); + var node = createSynthesizedNode(244 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -56966,7 +57658,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -56978,7 +57670,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56996,7 +57688,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244 /* ImportDeclaration */); + var node = createSynthesizedNode(247 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -57014,7 +57706,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245 /* ImportClause */); + var node = createSynthesizedNode(248 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -57028,7 +57720,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246 /* NamespaceImport */); + var node = createSynthesizedNode(249 /* NamespaceImport */); node.name = name; return node; } @@ -57040,7 +57732,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247 /* NamedImports */); + var node = createSynthesizedNode(250 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -57052,7 +57744,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248 /* ImportSpecifier */); + var node = createSynthesizedNode(251 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -57066,7 +57758,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249 /* ExportAssignment */); + var node = createSynthesizedNode(252 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -57083,7 +57775,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ExportDeclaration */); + var node = createSynthesizedNode(253 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -57101,7 +57793,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251 /* NamedExports */); + var node = createSynthesizedNode(254 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -57113,7 +57805,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252 /* ExportSpecifier */); + var node = createSynthesizedNode(255 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -57128,7 +57820,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254 /* ExternalModuleReference */); + var node = createSynthesizedNode(257 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -57141,7 +57833,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255 /* JsxElement */); + var node = createSynthesizedNode(258 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -57157,7 +57849,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57173,7 +57865,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257 /* JsxOpeningElement */); + var node = createSynthesizedNode(260 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57189,7 +57881,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258 /* JsxClosingElement */); + var node = createSynthesizedNode(261 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -57201,7 +57893,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259 /* JsxFragment */); + var node = createSynthesizedNode(262 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -57217,7 +57909,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262 /* JsxAttribute */); + var node = createSynthesizedNode(265 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -57231,7 +57923,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263 /* JsxAttributes */); + var node = createSynthesizedNode(266 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -57243,7 +57935,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -57255,7 +57947,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265 /* JsxExpression */); + var node = createSynthesizedNode(268 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -57269,7 +57961,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266 /* CaseClause */); + var node = createSynthesizedNode(269 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -57283,7 +57975,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267 /* DefaultClause */); + var node = createSynthesizedNode(270 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -57295,7 +57987,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268 /* HeritageClause */); + var node = createSynthesizedNode(271 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -57308,7 +58000,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269 /* CatchClause */); + var node = createSynthesizedNode(272 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -57323,7 +58015,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270 /* PropertyAssignment */); + var node = createSynthesizedNode(273 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -57338,7 +58030,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -57352,7 +58044,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272 /* SpreadAssignment */); + var node = createSynthesizedNode(275 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -57365,7 +58057,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273 /* EnumMember */); + var node = createSynthesizedNode(276 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -57386,7 +58078,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274 /* SourceFile */); + var updated = createSynthesizedNode(277 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -57470,7 +58162,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301 /* NotEmittedStatement */); + var node = createSynthesizedNode(304 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -57482,7 +58174,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(308 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57494,7 +58186,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(307 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57509,7 +58201,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(302 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(305 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -57525,7 +58217,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 === 303 /* CommaListExpression */) { + if (node.kind === 306 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -57535,7 +58227,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303 /* CommaListExpression */); + var node = createSynthesizedNode(306 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -57548,14 +58240,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275 /* Bundle */); + var node = ts.createNode(278 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276 /* UnparsedSource */); + var node = ts.createNode(279 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -57563,7 +58255,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277 /* InputFiles */); + var node = ts.createNode(280 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -57706,7 +58398,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 === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -58217,7 +58909,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -58235,13 +58927,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -58268,7 +58960,7 @@ var ts; } else { switch (callee.kind) { - case 185 /* PropertyAccessExpression */: { + case 187 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58281,7 +58973,7 @@ var ts; } break; } - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58341,9 +59033,9 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -58668,7 +59360,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 === 191 /* ParenthesizedExpression */) { + if (skipped.kind === 193 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -58702,8 +59394,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(200 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -58712,7 +59404,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 203 /* YieldExpression */) { + && operand.kind === 205 /* YieldExpression */) { return false; } return true; @@ -58800,7 +59492,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -58815,7 +59507,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -58829,8 +59521,7 @@ 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 === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 303 /* CommaListExpression */ + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } @@ -58848,10 +59539,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 /* ClassExpression */ || - check.kind === 192 /* FunctionExpression */ || - check.kind === 303 /* CommaListExpression */ || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) + return check.kind === 207 /* ClassExpression */ || + check.kind === 194 /* FunctionExpression */ || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -58865,9 +59555,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.createParen(expression); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -58890,7 +59580,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -58928,7 +59618,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -58939,27 +59629,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { + if (kind === 194 /* FunctionExpression */ || kind === 195 /* 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 === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { + if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: return ts.createParenthesizedType(member); @@ -58970,8 +59660,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 172 /* InferType */: + case 177 /* TypeOperator */: + case 174 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -58997,25 +59687,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: node = node.operand; continue; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: node = node.left; continue; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: node = node.condition; continue; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: - node = node.expression; - continue; - case 302 /* PartiallyEmittedExpression */: + case 210 /* AsExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 211 /* NonNullExpression */: + case 305 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -59023,12 +59713,17 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || + node.kind === 306 /* CommaListExpression */; + } + ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; @@ -59039,13 +59734,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 209 /* NonNullExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 211 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -59070,7 +59765,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { node = node.expression; } return node; @@ -59078,11 +59773,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - 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 302 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -59100,7 +59795,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 191 /* ParenthesizedExpression */ + return node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -59165,10 +59860,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -59287,7 +59982,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -59299,11 +59994,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -59336,11 +60031,11 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 204 /* SpreadElement */: - case 272 /* SpreadAssignment */: + case 206 /* SpreadElement */: + case 275 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -59352,7 +60047,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -59364,7 +60059,7 @@ var ts; : propertyName; } break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -59376,7 +60071,7 @@ var ts; : propertyName; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -59394,13 +60089,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -59440,11 +60135,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -59568,7 +60263,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -59605,7 +60300,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { return node; } switch (kind) { @@ -59660,217 +60355,221 @@ var ts; case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168 /* TupleType */: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* UnionType */: + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 169 /* OptionalType */: + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* RestType */: + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 171 /* ConditionalType */: + case 173 /* 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 172 /* InferType */: + case 174 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179 /* ImportType */: + case 181 /* 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 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177 /* MappedType */: + case 179 /* 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 178 /* LiteralType */: + case 180 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182 /* BindingElement */: + case 184 /* 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 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* FunctionExpression */: + case 194 /* 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 193 /* ArrowFunction */: + case 195 /* 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 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201 /* ConditionalExpression */: + case 203 /* 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 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 213 /* Block */: + case 216 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 216 /* ExpressionStatement */: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* IfStatement */: + case 219 /* ExpressionStatement */: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* 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 218 /* DoStatement */: + case 221 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: + case 224 /* 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 222 /* ForOfStatement */: + case 225 /* 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 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234 /* FunctionDeclaration */: + case 237 /* 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 235 /* ClassDeclaration */: + case 238 /* 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 236 /* InterfaceDeclaration */: + case 239 /* 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 237 /* TypeAliasDeclaration */: + case 240 /* 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 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250 /* ExportDeclaration */: + case 253 /* 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 251 /* NamedExports */: + case 254 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -59916,17 +60615,17 @@ var ts; return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 212 /* SemicolonClassElement */: - case 215 /* EmptyStatement */: - case 206 /* OmittedExpression */: - case 231 /* DebuggerStatement */: - case 301 /* NotEmittedStatement */: + case 215 /* SemicolonClassElement */: + case 218 /* EmptyStatement */: + case 208 /* OmittedExpression */: + case 234 /* DebuggerStatement */: + case 304 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -59993,49 +60692,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* NewExpression */: + case 190 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -60043,123 +60742,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ArrowFunction */: + case 195 /* 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 191 /* ParenthesizedExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208 /* AsExpression */: + case 210 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 213 /* Block */: + case 216 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219 /* WhileStatement */: - case 226 /* WithStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60168,7 +60867,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60176,139 +60875,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -60381,7 +61080,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 !== 207 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -60625,7 +61324,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -60772,7 +61470,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -60818,7 +61516,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -60826,13 +61524,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + case 246 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -60862,13 +61560,13 @@ var ts; } } break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -60876,7 +61574,7 @@ var ts; } } break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -60896,7 +61594,7 @@ var ts; } } break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -61512,13 +62210,14 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -61542,14 +62241,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* 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 === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -61577,16 +62276,18 @@ var ts; */ function saveStateAndInvoke(node, f) { // Save state - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } /** @@ -61596,15 +62297,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 240 /* ModuleBlock */: - case 213 /* Block */: - currentScope = node; + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 243 /* ModuleBlock */: + case 216 /* Block */: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -61616,7 +62318,11 @@ 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 === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } + if (ts.isClassDeclaration(node)) { + // XXX: should probably also cover interfaces and type aliases that can have type variables? + currentNameScope = node; } break; } @@ -61660,10 +62366,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -61684,13 +62390,13 @@ var ts; return node; } switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -61710,11 +62416,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 250 /* ExportDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 245 /* ImportClause */ || - (node.kind === 243 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 254 /* ExternalModuleReference */)) { + if (node.kind === 253 /* ExportDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 248 /* ImportClause */ || + (node.kind === 246 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 257 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -61756,7 +62462,7 @@ var ts; case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -61797,6 +62503,8 @@ var ts; // TypeScript accessibility and readonly modifiers are elided. case 167 /* ArrayType */: case 168 /* TupleType */: + case 169 /* OptionalType */: + case 170 /* RestType */: case 166 /* TypeLiteral */: case 161 /* TypePredicate */: case 148 /* TypeParameter */: @@ -61812,36 +62520,36 @@ var ts; 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 */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 175 /* ParenthesizedType */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: // TypeScript type nodes are elided. case 160 /* IndexSignature */: // TypeScript index signatures are elided. case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; 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 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; case 155 /* Constructor */: return visitConstructor(node); - case 236 /* InterfaceDeclaration */: + case 239 /* 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61852,7 +62560,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61863,13 +62571,13 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); case 154 /* MethodDeclaration */: @@ -61882,13 +62590,13 @@ var ts; case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case 149 /* Parameter */: @@ -61901,35 +62609,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -61965,7 +62673,7 @@ var ts; var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) @@ -62008,7 +62716,7 @@ var ts; var statements = [classStatement]; // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -62369,7 +63077,7 @@ var ts; // // super(...arguments); // - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } // Add the property initializers. Transforms this: @@ -62411,7 +63119,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -62448,7 +63156,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -62495,7 +63203,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -62798,7 +63506,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } /** @@ -62925,8 +63633,8 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -62948,8 +63656,8 @@ var ts; return serializeTypeNode(node.type); case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: @@ -63037,7 +63745,7 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return serializeTypeNode(node.type); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -63052,7 +63760,7 @@ var ts; return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -63072,18 +63780,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: return serializeUnionOrIntersectionType(node); case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: case 142 /* UnknownKeyword */: - case 174 /* ThisType */: - case 179 /* ImportType */: + case 176 /* ThisType */: + case 181 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63096,7 +63804,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -63135,7 +63843,7 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); @@ -63182,7 +63890,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. + name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -63516,7 +64224,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -63597,7 +64305,7 @@ var ts; * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -63621,7 +64329,7 @@ var ts; // enum body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63646,7 +64354,7 @@ var ts; // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63694,7 +64402,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } /** * Transforms the value of an enum member. @@ -63772,12 +64480,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 === 274 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 277 /* 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 === 238 /* EnumDeclaration */) { + if (node.kind === 241 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -63839,7 +64547,7 @@ var ts; // module body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63863,7 +64571,7 @@ var ts; // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63896,7 +64604,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240 /* ModuleBlock */) { + if (body.kind === 243 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -63942,13 +64650,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 !== 240 /* ModuleBlock */) { + if (body.kind !== 243 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -63989,7 +64697,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 246 /* NamespaceImport */) { + if (node.kind === 249 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -64144,17 +64852,17 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -64221,16 +64929,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(271 /* ShorthandPropertyAssignment */); + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(239 /* ModuleDeclaration */); + context.enableEmitNotification(242 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; } /** * Hook for node emit. @@ -64291,9 +64999,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -64331,9 +65039,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 !== 274 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); + if (container && container.kind !== 277 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -64468,15 +65176,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -64485,27 +65193,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - 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 */: + case 216 /* Block */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 229 /* WithStatement */: + case 231 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -64540,7 +65248,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -64706,7 +65414,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 === 193 /* ArrowFunction */; + var isArrowFunction = node.kind === 195 /* 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 @@ -64779,11 +65487,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -64827,11 +65535,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -64863,7 +65571,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -64962,25 +65670,25 @@ var ts; return node; } switch (node.kind) { - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitVoidExpression(node); case 155 /* Constructor */: return visitConstructorDeclaration(node); @@ -64990,19 +65698,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); case 149 /* Parameter */: return visitParameter(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -65036,7 +65744,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -65048,7 +65756,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 === 272 /* SpreadAssignment */) { + if (e.kind === 275 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -65057,7 +65765,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -65075,7 +65783,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 !== 184 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -65214,13 +65922,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -65388,11 +66096,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -65436,11 +66144,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -65472,7 +66180,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -65585,13 +66293,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -65601,13 +66309,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -65682,7 +66390,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265 /* JsxExpression */) { + else if (node.kind === 268 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -65776,7 +66484,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255 /* JsxElement */) { + if (node.kind === 258 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -66082,7 +66790,7 @@ var ts; return node; } switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66315,13 +67023,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 225 /* ReturnStatement */ + && node.kind === 228 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -66349,63 +67057,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return visitClassExpression(node); case 149 /* Parameter */: return visitParameter(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -66416,28 +67124,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitMetaProperty(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -66524,14 +67232,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 === 224 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -66542,7 +67250,7 @@ var ts; } } else { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -66659,7 +67367,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -66723,7 +67431,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), /*location*/ extendsClauseElement)); } } @@ -66842,11 +67550,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 225 /* ReturnStatement */) { + if (statement.kind === 228 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 217 /* IfStatement */) { + else if (statement.kind === 220 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -66854,7 +67562,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 213 /* Block */) { + else if (statement.kind === 216 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -66912,7 +67620,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -66922,8 +67630,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 /* BinaryExpression */ - || superCallExpression.left.kind !== 187 /* CallExpression */) { + if (superCallExpression.kind !== 202 /* BinaryExpression */ + || superCallExpression.left.kind !== 189 /* 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. @@ -67038,7 +67746,7 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -67052,7 +67760,7 @@ var ts; function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -67104,7 +67812,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ - ts.startOnNewLine(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) @@ -67120,7 +67828,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -67140,7 +67848,7 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return statements; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -67154,8 +67862,8 @@ var ts; // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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()); @@ -67186,7 +67894,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: @@ -67230,7 +67938,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -67248,7 +67956,7 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); + var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. @@ -67391,7 +68099,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 === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -67436,7 +68144,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193 /* ArrowFunction */); + ts.Debug.assert(node.kind === 195 /* 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 @@ -67504,10 +68212,10 @@ 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 191 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + case 193 /* ParenthesizedExpression */: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 202 /* BinaryExpression */: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); } @@ -67525,9 +68233,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 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -67569,7 +68277,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -67728,14 +68436,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -67793,11 +68501,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -67886,13 +68594,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -67991,11 +68699,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -68159,7 +68867,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -68176,7 +68884,7 @@ var ts; ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { @@ -68285,10 +68993,10 @@ var ts; case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -68540,7 +69248,7 @@ var ts; statements.push(funcStatements[classBodyStart]); classBodyStart++; // Add the class alias following the declaration. - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } // Find the trailing 'return' statement (4) while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { @@ -68677,7 +69385,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -68944,9 +69652,9 @@ var ts; context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(193 /* ArrowFunction */); - context.enableEmitNotification(192 /* FunctionExpression */); - context.enableEmitNotification(234 /* FunctionDeclaration */); + context.enableEmitNotification(195 /* ArrowFunction */); + context.enableEmitNotification(194 /* FunctionExpression */); + context.enableEmitNotification(237 /* FunctionDeclaration */); } } /** @@ -68987,10 +69695,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 235 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -69072,11 +69780,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -69084,7 +69792,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -69137,15 +69845,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257 /* JsxOpeningElement */); - context.enableEmitNotification(258 /* JsxClosingElement */); - context.enableEmitNotification(256 /* JsxSelfClosingElement */); + context.enableEmitNotification(260 /* JsxOpeningElement */); + context.enableEmitNotification(261 /* JsxClosingElement */); + context.enableEmitNotification(259 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(270 /* PropertyAssignment */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(273 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -69164,9 +69872,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -69498,13 +70206,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -69517,24 +70225,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return visitBreakStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return visitContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -69555,21 +70263,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitConditionalExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69582,9 +70290,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -69760,7 +70468,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } /** @@ -69812,7 +70520,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -69824,7 +70532,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -69948,7 +70656,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* Statement */, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -70101,7 +70809,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -70200,35 +70908,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: return transformAndEmitBlock(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return transformAndEmitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return transformAndEmitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return transformAndEmitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return transformAndEmitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -70265,7 +70973,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -70416,7 +71124,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -70426,7 +71134,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -70487,7 +71195,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); @@ -70510,7 +71218,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -70658,7 +71366,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -70671,7 +71379,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -71534,7 +72242,7 @@ var ts; // indicate entry into a protected region by pushing the label numbers // for each block in the protected region. var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, [ ts.createArrayLiteral([ createLabel(startLabel), @@ -71548,7 +72256,7 @@ var ts; if (markLabelEnd) { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -71706,7 +72414,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -71900,11 +72608,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported 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.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(277 /* 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. @@ -71997,7 +72705,7 @@ var ts; // // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, + ts.createExpressionStatement(ts.createCall(define, /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ // Add the dependency array argument: // @@ -72048,9 +72756,9 @@ var ts; ts.createIdentifier("exports") ])) ]), - ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -72074,7 +72782,7 @@ var ts; // } // })(function ...) var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, + ts.createExpressionStatement(ts.createCall(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // @@ -72153,7 +72861,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. @@ -72208,7 +72916,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); @@ -72226,23 +72934,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -72269,17 +72977,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -72373,7 +73081,7 @@ var ts; ts.createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; @@ -72468,7 +73176,7 @@ var ts; if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -72536,7 +73244,7 @@ var ts; var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(node.name, createRequireCall(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( @@ -72549,7 +73257,7 @@ var ts; } else { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -72588,13 +73296,13 @@ var ts; for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { // export * from "mod"; - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } /** @@ -72700,7 +73408,7 @@ var ts; statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); } if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -72761,7 +73469,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -72816,10 +73524,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -72949,10 +73657,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), @@ -72973,7 +73681,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, location, allowComments) { - var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -73018,7 +73726,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -73082,10 +73790,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -73106,7 +73814,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -73181,7 +73889,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -73257,11 +73965,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - 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. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(277 /* 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. @@ -73323,7 +74031,7 @@ var ts; var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) @@ -73482,7 +74190,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -73507,7 +74215,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250 /* ExportDeclaration */) { + if (externalImport.kind !== 253 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -73561,9 +74269,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) ])), - ts.createStatement(ts.createCall(exportFunction, + ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) ], /*multiline*/ true)); } @@ -73585,19 +74293,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -73613,7 +74321,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { @@ -73622,7 +74330,7 @@ var ts; // emit as: // // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, /*typeArguments*/ undefined, [parameterName]))); } break; @@ -73647,15 +74355,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -73756,7 +74464,7 @@ var ts; var name = ts.getLocalName(node); hoistVariableDeclaration(name); // Rewrite the class declaration into an assignment of a class expression. - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -73793,7 +74501,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -73831,7 +74539,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 === 274 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 277 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -73895,7 +74603,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 === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -73957,10 +74665,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -74112,7 +74820,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -74140,43 +74848,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitDefaultClause(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitTryStatement(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -74359,7 +75067,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 200 /* BinaryExpression */) { + && node.kind === 202 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -74424,7 +75132,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274 /* SourceFile */; + return container !== undefined && container.kind === 277 /* SourceFile */; } else { return false; @@ -74457,7 +75165,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -74505,7 +75213,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -74541,10 +75249,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -74637,14 +75345,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* 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 === 199 /* PostfixUnaryExpression */) { + if (node.kind === 201 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -74666,7 +75374,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -74705,7 +75413,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274 /* SourceFile */); + context.enableEmitNotification(277 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -74734,10 +75442,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -74844,7 +75552,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74873,7 +75581,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74920,7 +75628,7 @@ var ts; 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 === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* 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 : @@ -74939,7 +75647,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 === 235 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 238 /* 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 : @@ -75030,7 +75738,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -75044,7 +75752,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234 /* FunctionDeclaration */: + case 237 /* 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 : @@ -75100,7 +75808,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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 : @@ -75113,7 +75821,7 @@ 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 163 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -75128,10 +75836,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159 /* ConstructSignature */: @@ -75145,17 +75853,17 @@ var ts; 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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -75170,7 +75878,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 235 /* ClassDeclaration */) { + if (node.parent.parent.kind === 238 /* 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 : @@ -75267,7 +75975,13 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + // If it is visible via `// `, then we should just use that + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -75322,10 +76036,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -75353,7 +76067,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -75451,7 +76165,7 @@ var ts; return name; } else { - if (name.kind === 181 /* ArrayBindingPattern */) { + if (name.kind === 183 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -75459,7 +76173,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206 /* OmittedExpression */) { + if (elem.kind === 208 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -75517,7 +76231,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 /* Parameter */ @@ -75539,20 +76253,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return false; } return false; @@ -75606,7 +76320,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -75618,7 +76332,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -75645,7 +76359,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 === 246 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 249 /* 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; @@ -75750,14 +76464,14 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* 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 207 /* ExpressionWithTypeArguments */: { + case 209 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -75811,7 +76525,7 @@ var ts; return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -75825,7 +76539,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171 /* ConditionalType */: { + case 173 /* 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); @@ -75843,7 +76557,7 @@ var ts; case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179 /* ImportType */: { + case 181 /* 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)); @@ -75882,7 +76596,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250 /* ExportDeclaration */: { + case 253 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -75891,7 +76605,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -75921,10 +76635,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -75945,24 +76659,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 240 /* 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 236 /* InterfaceDeclaration */: { + case 239 /* 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 234 /* FunctionDeclaration */: { + case 237 /* 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 239 /* ModuleDeclaration */: { + case 242 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240 /* ModuleBlock */) { + if (inner && inner.kind === 243 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -75983,7 +76697,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 235 /* ClassDeclaration */: { + case 238 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -76023,7 +76737,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(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"); // TODO: GH#18217 @@ -76053,10 +76767,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238 /* EnumDeclaration */: { + case 241 /* 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; @@ -76075,7 +76789,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239 /* ModuleDeclaration */) { + if (input.kind === 242 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -76096,7 +76810,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206 /* OmittedExpression */) { + if (e.kind === 208 /* OmittedExpression */) { return; } if (e.name) { @@ -76150,7 +76864,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 === 274 /* SourceFile */; + var parentIsFile = node.parent.kind === 277 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -76171,7 +76885,7 @@ var ts; var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3 /* MultiLineCommentTrivia */) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -76185,7 +76899,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -76198,7 +76912,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* InterfaceDeclaration */) { return true; } return false; @@ -76227,7 +76941,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: @@ -76237,17 +76951,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - 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 */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 217 /* VariableStatement */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return true; } return false; @@ -76264,14 +76978,14 @@ var ts; case 153 /* MethodSignature */: case 158 /* CallSignature */: case 160 /* IndexSignature */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 148 /* TypeParameter */: - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: case 162 /* TypeReference */: - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 179 /* ImportType */: + case 181 /* ImportType */: return true; } return false; @@ -76347,7 +77061,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(306 /* Count */); + var enabledSyntaxKindFeatures = new Array(309 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -76682,7 +77396,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap @@ -76692,7 +77405,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 277 /* 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)); @@ -76783,7 +77496,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** * Emits a mapping. @@ -76843,6 +77555,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -76853,50 +77566,55 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { // empty } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); // First, decode the old component sourcemap - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -76913,7 +77631,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -76968,13 +77686,15 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - // 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 - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + // 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 + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -77090,7 +77810,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 304 /* 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 */; @@ -77111,7 +77831,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 === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -77453,7 +78173,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275 /* Bundle */) { + if (sourceFile.kind === 278 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; @@ -77588,6 +78308,11 @@ var ts; // Setup and perform the transformation to retrieve declarations from the input files var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + // Checker wont collect the linked aliases since thats only done when declaration is enabled. + // Do that here when emitting only dts files + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -77615,9 +78340,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71 /* Identifier */) { + resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -77717,9 +78455,9 @@ var ts; break; } switch (node.kind) { - case 274 /* SourceFile */: return printFile(node); - case 275 /* Bundle */: return printBundle(node); - case 276 /* UnparsedSource */: return printUnparsedSource(node); + case 277 /* SourceFile */: return printFile(node); + case 278 /* Bundle */: return printBundle(node); + case 279 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -77864,7 +78602,7 @@ var ts; } return pipelineEmitWithoutComments; case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { return pipelineEmitWithSourceMap; } // falls through @@ -77890,7 +78628,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); + ts.Debug.assert(hint !== 0 /* SourceFile */); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -77909,7 +78647,7 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 276 /* UnparsedSource */: + case 279 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: @@ -77954,7 +78692,7 @@ var ts; return emitTypeReference(node); case 163 /* FunctionType */: return emitFunctionType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 164 /* ConstructorType */: return emitConstructorType(node); @@ -77966,178 +78704,181 @@ var ts; return emitArrayType(node); case 168 /* TupleType */: return emitTupleType(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return emitOptionalType(node); + case 171 /* UnionType */: return emitUnionType(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return emitIntersectionType(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return emitConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return emitInferType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return emitParenthesizedType(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return emitThisType(); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return emitTypeOperator(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return emitMappedType(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return emitLiteralType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return emitImportTypeNode(node); - case 279 /* JSDocAllType */: + case 282 /* JSDocAllType */: write("*"); return; - case 280 /* JSDocUnknownType */: + case 283 /* JSDocUnknownType */: write("?"); return; - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 285 /* JSDocVariadicType */: - return emitJSDocVariadicType(node); + case 170 /* RestType */: + case 288 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return emitBindingElement(node); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return emitTemplateSpan(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 213 /* Block */: + case 216 /* Block */: return emitBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return emitVariableStatement(node); - case 215 /* EmptyStatement */: + case 218 /* EmptyStatement */: return emitEmptyStatement(); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return emitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return emitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return emitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return emitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return emitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return emitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return emitForOfStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return emitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return emitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return emitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return emitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return emitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return emitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return emitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return emitTryStatement(node); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return emitClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return emitModuleBlock(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return emitCaseBlock(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return emitImportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return emitImportClause(node); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return emitNamespaceImport(node); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return emitNamedImports(node); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return emitImportSpecifier(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return emitExportDeclaration(node); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return emitNamedExports(node); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return emitExportSpecifier(node); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return; // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 258 /* JsxClosingElement */: - case 261 /* JsxClosingFragment */: + case 261 /* JsxClosingElement */: + case 264 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return emitJsxAttribute(node); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return emitJsxAttributes(node); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return emitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return emitDefaultClause(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return emitHeritageClause(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -78172,71 +78913,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return emitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return emitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return emitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return emitArrowFunction(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return emitDeleteExpression(node); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return emitVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return emitAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return emitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return emitConditionalExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return emitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return emitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return emitSpreadExpression(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return emitClassExpression(node); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: return emitAsExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return emitNonNullExpression(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return emitJsxElement(node); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return emitCommaList(node); } } @@ -78253,7 +78994,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 /* Bundle */ ? node : undefined; + var bundle = node.kind === 278 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -78379,7 +79120,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -78548,7 +79289,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -78557,6 +79298,10 @@ var ts; emitList(node, node.elementTypes, 272 /* TupleTypeElements */); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260 /* UnionTypeConstituents */); } @@ -78838,7 +79583,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 === 198 /* PrefixUnaryExpression */ + return operand.kind === 200 /* 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 */))); } @@ -78958,7 +79703,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217 /* IfStatement */) { + if (node.elseStatement.kind === 220 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -79029,7 +79774,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { emit(node); } else { @@ -79131,7 +79876,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272 /* VariableDeclarationList */); } @@ -79324,7 +80069,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239 /* ModuleDeclaration */) { + while (body.kind === 242 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -80249,7 +80994,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -80314,81 +81059,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: ts.forEach(node.statements, generateNames); break; - case 228 /* LabeledStatement */: - case 226 /* WithStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 231 /* LabeledStatement */: + case 229 /* WithStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: generateNames(node.statement); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: generateNames(node.declarationList); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: generateNames(node.importClause); break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -80397,8 +81142,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 152 /* PropertyDeclaration */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -80584,17 +81329,17 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 252 /* ExportAssignment */: return generateNameForExportDefault(); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return generateNameForClassExpression(); case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -81255,17 +82000,20 @@ var ts; } return context; } - function formatLocation(file, start, host) { + /* @internal */ + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -81284,11 +82032,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -82015,7 +82763,16 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + // Use local caches + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + // Before falling back to the host + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -82275,10 +83032,10 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: - case 232 /* VariableDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: + case 235 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -82286,41 +83043,41 @@ var ts; } } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268 /* HeritageClause */: + case 271 /* 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 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -82333,25 +83090,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 235 /* ClassDeclaration */: + case 238 /* 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 */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* 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 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); } break; case 152 /* PropertyDeclaration */: @@ -82373,11 +83130,11 @@ var ts; return; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -83043,14 +83800,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -84704,11 +85461,12 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - // Note: fromSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + // Note: importingSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -84721,7 +85479,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); 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); @@ -84739,13 +85497,13 @@ var ts; 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); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } 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); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -84815,11 +85573,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0 /* EqualTo */) { resolvedParts.pop(); originalParts.pop(); } @@ -84853,17 +85612,16 @@ var ts; return [target]; } /** - * Looks for a existing imports that use symlinks to this module. + * Looks for existing imports that use symlinks to this module. * Only if no symlink is available, the real path will be used. */ - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -84939,7 +85697,7 @@ var ts; var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // 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))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); @@ -85347,7 +86105,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; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; 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); @@ -85879,16 +86637,20 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */) ? ".jsx" /* Jsx */ : ".js" /* Js */); + var newExtension = ts.fileExtensionIs(inputFileName, ".json" /* Json */) ? ".json" /* Json */ : + ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -86060,9 +86822,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -86112,7 +86871,7 @@ var ts; // Everything is broken - we don't even know what to watch. Give up. return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { // Watch this file @@ -86139,7 +86898,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -86344,14 +87103,18 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -86359,7 +87122,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -86655,12 +87422,12 @@ var ts; } // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -86729,7 +87496,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; diff --git a/lib/zh-cn/diagnosticMessages.generated.json b/lib/zh-cn/diagnosticMessages.generated.json index 2d2168ab781..aaf6a7101a8 100644 --- a/lib/zh-cn/diagnosticMessages.generated.json +++ b/lib/zh-cn/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "命名空间声明不能位于与之合并的类或函数前", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "只允许在命名空间或模块中使用命名空间声明。", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "命名空间样式导入不能调用或构造,并将在运行时导致失败。", - "A_non_dry_build_would_build_project_0_6357": "非干燥生成将生成项目“{0}”", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非干燥生成将删除以下文件: {0}", + "A_non_dry_build_would_build_project_0_6357": "非 -dry 生成将生成项目“{0}”", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 -dry 生成将删除以下文件: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "只允许在函数或构造函数实现中使用参数初始化表达式。", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "不能使用 rest 参数声明参数属性。", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "只允许在构造函数实现中使用参数属性。", diff --git a/lib/zh-tw/diagnosticMessages.generated.json b/lib/zh-tw/diagnosticMessages.generated.json index c1e5fd594a6..0ffe456d728 100644 --- a/lib/zh-tw/diagnosticMessages.generated.json +++ b/lib/zh-tw/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "命名空間宣告的位置不得先於其要合併的類別或函式。", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "只有命名空間或模組才允許命名空間宣告。", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "命名空間樣式的匯入無法加以呼叫或建構,而且會導致執行階段失敗。", - "A_non_dry_build_would_build_project_0_6357": "非 DRY 的組建會建置專案 '{0}'", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 DRY 的組建會刪除下列檔案: {0}", + "A_non_dry_build_would_build_project_0_6357": "非 -dry 組建會建置專案 '{0}'", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 -dry 組建會刪除下列檔案: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "只有函式或建構函式實作才可使用參數初始設定式。", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "無法使用剩餘參數宣告參數屬性。", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "建構函式實作中只可有一個參數屬性。", diff --git a/scripts/createBenchmark.ts b/scripts/createBenchmark.ts index 659df53c915..6148d80bf2c 100644 --- a/scripts/createBenchmark.ts +++ b/scripts/createBenchmark.ts @@ -32,7 +32,7 @@ sourceFiles.forEach(f=> { }); var compilerSoruces = `var compilerSources = ${JSON.stringify(rawCompilerSources) };`; -// .js code for the compiler, what we are actuallty testing +// .js code for the compiler, what we are actually testing var rawCompilerJavaScript = fs.readFileSync(path.join(tsBuildDir, "tsc.js")).toString(); rawCompilerJavaScript = rawCompilerJavaScript.replace("ts.executeCommandLine(ts.sys.args);", ""); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 207d7317078..3a19ca63b3f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -607,7 +607,7 @@ namespace ts { ResolvedBaseConstructorType, DeclaredType, ResolvedReturnType, - ResolvedBaseConstraint, + ImmediateBaseConstraint, } const enum CheckMode { @@ -2268,7 +2268,7 @@ namespace ts { function resolveESModuleSymbol(moduleSymbol: Symbol | undefined, referencingLocation: Node, dontResolveAlias: boolean): Symbol | undefined { const symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) { + if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable)) && !getDeclarationOfKind(symbol, SyntaxKind.SourceFile)) { error(referencingLocation, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol!)); return symbol; } @@ -2463,17 +2463,26 @@ namespace ts { * 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: Symbol): Symbol | undefined { + function getContainersOfSymbol(symbol: Symbol, enclosingDeclaration: Node | undefined): Symbol[] | undefined { const container = getParentOfSymbol(symbol); if (container) { - return container; + const additionalContainers = mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); + if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, SymbolFlags.Namespace, /*externalOnly*/ false)) { + return concatenate([container], additionalContainers); // This order expresses a preference for the real container if it is in scope + } + return append(additionalContainers, container); } - const candidate = forEach(symbol.declarations, d => !isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined); - if (!candidate) { + const candidates = mapDefined(symbol.declarations, d => !isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined); + if (!length(candidates)) { return undefined; } - const alias = getAliasForSymbolInContainer(candidate, symbol); - return alias ? candidate : undefined; + return mapDefined(candidates, candidate => getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined); + + function fileSymbolIfFileSymbolExportEqualsContainer(d: Declaration) { + const fileSymbol = getExternalModuleContainer(d); + const exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get(InternalSymbolName.ExportEquals); + return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + } } function getAliasForSymbolInContainer(container: Symbol, symbol: Symbol) { @@ -2759,6 +2768,56 @@ namespace ts { return access.accessibility === SymbolAccessibility.Accessible; } + function isAnySymbolAccessible(symbols: Symbol[] | undefined, enclosingDeclaration: Node, initialSymbol: Symbol, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult | undefined { + if (!length(symbols)) return; + + let hadAccessibleChain: Symbol | undefined; + for (const symbol of symbols!) { + // Symbol is accessible if it by itself is accessible + const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false); + if (accessibleSymbolChain) { + hadAccessibleChain = symbol; + const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible); + if (hasAccessibleDeclarations) { + return hasAccessibleDeclarations; + } + } + else { + if (some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + // Any meaning of a module symbol is always accessible via an `import` type + return { + accessibility: SymbolAccessibility.Accessible + }; + } + } + + // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible. + // It could be a qualified symbol and hence verify the path + // e.g.: + // module m { + // export class c { + // } + // } + // const x: typeof m.c + // In the above example when we start with checking if typeof m.c symbol is accessible, + // we are going to see if c can be accessed in scope directly. + // 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 + const parentResult = isAnySymbolAccessible(getContainersOfSymbol(symbol, enclosingDeclaration), enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible); + if (parentResult) { + return parentResult; + } + } + + if (hadAccessibleChain) { + return { + accessibility: SymbolAccessibility.NotAccessible, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, SymbolFlags.Namespace) : undefined, + }; + } + } + /** * Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested * @@ -2769,57 +2828,21 @@ namespace ts { */ function isSymbolAccessible(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult { if (symbol && enclosingDeclaration) { - const initialSymbol = symbol; - let meaningToLook = meaning; - while (symbol) { - // Symbol is accessible if it by itself is accessible - const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); - if (accessibleSymbolChain) { - const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible); - if (!hasAccessibleDeclarations) { - return { - accessibility: SymbolAccessibility.NotAccessible, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, SymbolFlags.Namespace) : undefined, - }; - } - return hasAccessibleDeclarations; - } - else { - if (some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - // Any meaning of a module symbol is always accessible via an `import` type - return { - accessibility: SymbolAccessibility.Accessible - }; - } - } - - // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible. - // It could be a qualified symbol and hence verify the path - // e.g.: - // module m { - // export class c { - // } - // } - // const x: typeof m.c - // In the above example when we start with checking if typeof m.c symbol is accessible, - // we are going to see if c can be accessed in scope directly. - // 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 = getContainerOfSymbol(symbol); + const result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible); + if (result) { + return result; } // 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 - const symbolExternalModule = forEach(initialSymbol.declarations, getExternalModuleContainer); + const symbolExternalModule = forEach(symbol.declarations, getExternalModuleContainer); if (symbolExternalModule) { const enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { accessibility: SymbolAccessibility.CannotBeNamed, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule) }; } @@ -2828,16 +2851,16 @@ namespace ts { // Just a local name that is not accessible return { accessibility: SymbolAccessibility.NotAccessible, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } return { accessibility: SymbolAccessibility.Accessible }; + } - function getExternalModuleContainer(declaration: Node) { - const node = findAncestor(declaration, hasExternalModuleSymbol); - return node && getSymbolOfNode(node); - } + function getExternalModuleContainer(declaration: Node) { + const node = findAncestor(declaration, hasExternalModuleSymbol); + return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration: Node) { @@ -3667,18 +3690,19 @@ namespace ts { /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { let accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & NodeBuilderFlags.UseOnlyExternalAliasing)); - let parentSymbol: Symbol | undefined; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - const parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent) { - const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); - if (parentChain) { - parentSymbol = parent; - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); + const parents = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration); + if (length(parents)) { + for (const parent of parents!) { + const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + if (parentChain) { + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); + break; + } } } } @@ -3689,11 +3713,12 @@ namespace ts { if ( // 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 && forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) && // If a parent symbol is an anonymous type, don't write it. !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { - + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + if (!endOfChain && !yieldModuleSymbol && !!forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return; + } return [symbol]; } } @@ -4255,8 +4280,8 @@ namespace ts { if (propertyName === TypeSystemPropertyName.ResolvedReturnType) { return !!(target).resolvedReturnType; } - if (propertyName === TypeSystemPropertyName.ResolvedBaseConstraint) { - const bc = (target).resolvedBaseConstraint; + if (propertyName === TypeSystemPropertyName.ImmediateBaseConstraint) { + const bc = (target).immediateBaseConstraint; return !!bc && bc !== circularConstraintType; } @@ -6854,15 +6879,21 @@ namespace ts { return type.resolvedBaseConstraint; function getBaseConstraint(t: Type): Type | undefined { - if (!pushTypeResolution(t, TypeSystemPropertyName.ResolvedBaseConstraint)) { + if (t.immediateBaseConstraint) { + return t.immediateBaseConstraint === noConstraintType ? undefined : t.immediateBaseConstraint; + } + if (!pushTypeResolution(t, TypeSystemPropertyName.ImmediateBaseConstraint)) { circular = true; + t.immediateBaseConstraint = circularConstraintType; return undefined; } const result = computeBaseConstraint(getSimplifiedType(t)); if (!popTypeResolution()) { circular = true; + t.immediateBaseConstraint = circularConstraintType; return undefined; } + t.immediateBaseConstraint = !result ? noConstraintType : result; return result; } @@ -9264,7 +9295,12 @@ namespace ts { resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - error(node, targetMeaning === SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + const errorMessage = targetMeaning === SymbolFlags.Value + ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here + : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; + + error(node, errorMessage, moduleName); + links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -14849,7 +14885,7 @@ namespace ts { const declarationContainer = getControlFlowContainer(declaration); let flowContainer = getControlFlowContainer(node); const isOuterVariable = flowContainer !== declarationContainer; - const isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + const isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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. @@ -14861,7 +14897,7 @@ namespace ts { // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). - const assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || + const assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.AnyOrUnknown) !== 0 || isInTypeQuery(node) || node.parent.kind === SyntaxKind.ExportSpecifier) || node.parent.kind === SyntaxKind.NonNullExpression || @@ -19458,7 +19494,8 @@ namespace ts { function getAssignedClassType(symbol: Symbol) { const decl = symbol.valueDeclaration; const assignmentSymbol = decl && decl.parent && - (isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { const prototype = forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -19592,7 +19629,7 @@ namespace ts { } const specifier = node.arguments[0]; const specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (let i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -27699,6 +27736,9 @@ namespace ts { // Initialize global symbol table let augmentations: ReadonlyArray[] | undefined; for (const file of host.getSourceFiles()) { + if (file.redirectInfo) { + continue; + } if (!isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals!); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 40a4c4d09d4..87d8297e74d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -971,7 +971,7 @@ "category": "Error", "code": 1339 }, - "Module '{0}' does not refer to a type, but is used as a type here.": { + "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?": { "category": "Error", "code": 1340 }, diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 9dbfdeceac0..7c8ec909eb5 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -272,10 +272,9 @@ namespace ts { } function parenthesizeForComputedName(expression: Expression): Expression { - return (isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken) || - expression.kind === SyntaxKind.CommaListExpression ? - createParen(expression) : - expression; + return isCommaSequence(expression) + ? createParen(expression) + : expression; } export function createComputedPropertyName(expression: Expression) { @@ -4166,8 +4165,7 @@ namespace 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 const emittedExpression = skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === SyntaxKind.BinaryExpression && (emittedExpression).operatorToken.kind === SyntaxKind.CommaToken || - emittedExpression.kind === SyntaxKind.CommaListExpression + return isCommaSequence(emittedExpression) ? createParen(e) : e; } @@ -4185,8 +4183,7 @@ namespace ts { */ export function parenthesizeDefaultExpression(e: Expression) { const check = skipPartiallyEmittedExpressions(e); - let needsParens = check.kind === SyntaxKind.CommaListExpression || - isBinaryExpression(check) && check.operatorToken.kind === SyntaxKind.CommaToken; + let needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { case SyntaxKind.ClassExpression: @@ -4378,13 +4375,18 @@ namespace ts { } export function parenthesizeConciseBody(body: ConciseBody): ConciseBody { - if (!isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === SyntaxKind.ObjectLiteralExpression) { + if (!isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === SyntaxKind.ObjectLiteralExpression)) { return setTextRange(createParen(body), body); } return body; } + export function isCommaSequence(node: Expression): node is BinaryExpression & {operatorToken: Token} | CommaListExpression { + return node.kind === SyntaxKind.BinaryExpression && (node).operatorToken.kind === SyntaxKind.CommaToken || + node.kind === SyntaxKind.CommaListExpression; + } + export const enum OuterExpressionKinds { Parentheses = 1 << 0, Assertions = 1 << 1, diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 489894631ff..1e4a793e566 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -7655,7 +7655,8 @@ namespace ts { } } - function isDeclarationFileName(fileName: string): boolean { + /** @internal */ + export function isDeclarationFileName(fileName: string): boolean { return fileExtensionIs(fileName, Extension.Dts); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 741514d2ef2..75cdcaea328 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2344,7 +2344,7 @@ namespace ts { const refPath = resolveProjectReferencePath(host, ref); // An absolute path pointing to the containing directory of the config file const basePath = getNormalizedAbsolutePath(getDirectoryPath(refPath), host.getCurrentDirectory()); - const sourceFile = host.getSourceFile(refPath, ScriptTarget.JSON) as JsonSourceFile; + const sourceFile = host.getSourceFile(refPath, ScriptTarget.JSON) as JsonSourceFile | undefined; if (sourceFile === undefined) { return undefined; } @@ -2823,10 +2823,14 @@ namespace ts { }; } + export interface ResolveProjectReferencePathHost { + fileExists(fileName: string): boolean; + } /** - * Returns the target config filename of a project reference + * Returns the target config filename of a project reference. + * Note: The file might not exist. */ - export function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName { + export function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName { if (!host.fileExists(ref.path)) { return combinePaths(ref.path, "tsconfig.json") as ResolvedConfigFileName; } diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 8dfe91a6cff..2be4d49d7b0 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -156,7 +156,6 @@ namespace ts { sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -216,17 +215,6 @@ namespace ts { sourceMapDataList = undefined!; } - interface SourceMapSection { - version: 3; - file: string; - sourceRoot?: string; - sources: string[]; - names?: string[]; - mappings: string; - sourcesContent?: (string | null)[]; - sections?: undefined; - } - type SourceMapSectionDefinition = | { offset: { line: number, column: number }, url: string } // Included for completeness | { offset: { line: number, column: number }, map: SourceMap }; @@ -299,7 +287,6 @@ namespace ts { } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** @@ -393,24 +380,29 @@ namespace ts { const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; const resolvedPathCache = createMap(); - sourcemaps.calculateDecodedMappings(originalMap, (raw): void => { + const absolutePathCache = createMap(); + const sourcemapIterator = sourcemaps.decodeMappings(originalMap); + for (let { value: raw, done } = sourcemapIterator.next(); !done; { value: raw, done } = sourcemapIterator.next()) { + const pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - const rawPath = originalMap.sources[raw.sourceIndex]; - const relativePath = originalMap.sourceRoot ? combinePaths(originalMap.sourceRoot, rawPath) : rawPath; - const combinedPath = combinePaths(getDirectoryPath(node.sourceMapPath!), relativePath); - if (!resolvedPathCache.has(combinedPath)) { - resolvedPathCache.set(combinedPath, getRelativePathToDirectoryOrUrl( + if (!resolvedPathCache.has(pathCacheKey)) { + const rawPath = originalMap.sources[raw.sourceIndex]; + const relativePath = originalMap.sourceRoot ? combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + const combinedPath = combinePaths(getDirectoryPath(node.sourceMapPath!), relativePath); + const resolvedPath = getRelativePathToDirectoryOrUrl( sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true - )); + ); + resolvedPathCache.set(pathCacheKey, resolvedPath); + absolutePathCache.set(pathCacheKey, getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath)); } - const resolvedPath = resolvedPathCache.get(combinedPath)!; - const absolutePath = getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath); + const resolvedPath = resolvedPathCache.get(pathCacheKey)!; + const absolutePath = absolutePathCache.get(pathCacheKey)!; // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? const newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); @@ -420,7 +412,7 @@ namespace ts { emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex, }; - }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } @@ -519,17 +511,19 @@ namespace ts { setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName: string, content: string | null) { - // 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 - const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + function setupSourceEntry(fileName: string, content: string | null, source?: string) { + if (!source) { + // 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 + const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - const source = getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, - fileName, - host.getCurrentDirectory(), - host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + source = getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, + fileName, + host.getCurrentDirectory(), + host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { @@ -577,6 +571,17 @@ namespace ts { } } + export interface SourceMapSection { + version: 3; + file: string; + sourceRoot?: string; + sources: string[]; + names?: string[]; + mappings: string; + sourcesContent?: (string | null)[]; + sections?: undefined; + } + const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function base64FormatEncode(inValue: number) { diff --git a/src/compiler/sourcemapDecoder.ts b/src/compiler/sourcemapDecoder.ts index 290f7699e5d..4248ac21829 100644 --- a/src/compiler/sourcemapDecoder.ts +++ b/src/compiler/sourcemapDecoder.ts @@ -190,7 +190,7 @@ namespace ts.sourcemaps { }; } - export function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { log?(s: string): void }): T[] { + function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { log?(s: string): void }): T[] { const decoder = decodeMappings(map); const positions = arrayFrom(decoder, processPosition); if (decoder.error) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 403d6a46e03..d096cba6c55 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2844,7 +2844,6 @@ namespace ts { inputSourceFileNames: string[]; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMapSources list sourceMapNames?: string[]; // Source map's names field - list of names that can be indexed in this source map sourceMapMappings: string; // Source map's mapping field - encoded source map spans - sourceMapDecodedMappings: SourceMapSpan[]; // Raw source map spans that were encoded into the sourceMapMappings } /** Return code used by getEmitOutput function to indicate status of the function */ @@ -3754,6 +3753,8 @@ namespace ts { aliasTypeArguments?: ReadonlyArray; // Alias type arguments (if any) /* @internal */ wildcardInstantiation?: Type; // Instantiation with type parameters mapped to wildcard type + /* @internal */ + immediateBaseConstraint?: Type; // Immediate base constraint cache } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e68f24536de..c5fa7d155d5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1855,7 +1855,7 @@ namespace ts { } export function getRightMostAssignedExpression(node: Expression): Expression { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; diff --git a/src/harness/client.ts b/src/harness/client.ts index 20748a9c54c..ebe97aea070 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -73,7 +73,7 @@ namespace ts.server { return { span: this.decodeSpan(codeEdit, fileName), newText: codeEdit.newText }; } - private processRequest(command: string, args?: T["arguments"]): T { + private processRequest(command: string, args: T["arguments"]): T { const request: protocol.Request = { seq: this.sequence, type: "request", @@ -278,9 +278,10 @@ namespace ts.server { const request = this.processRequest(CommandNames.DefinitionAndBoundSpan, args); const response = this.processResponse(request); + const body = Debug.assertDefined(response.body); // TODO: GH#18217 return { - definitions: response.body!.definitions.map(entry => ({ // TODO: GH#18217 + definitions: body.definitions.map(entry => ({ containerKind: ScriptElementKind.unknown, containerName: "", fileName: entry.file, @@ -288,7 +289,7 @@ namespace ts.server { kind: ScriptElementKind.unknown, name: "" })), - textSpan: this.decodeSpan(response.body!.textSpan, request.arguments.file) + textSpan: this.decodeSpan(body.textSpan, request.arguments.file) }; } @@ -341,8 +342,10 @@ namespace ts.server { })); } - getEmitOutput(_fileName: string): EmitOutput { - return notImplemented(); + getEmitOutput(file: string): EmitOutput { + const request = this.processRequest(protocol.CommandTypes.EmitOutput, { file }); + const response = this.processResponse(request); + return response.body; } getSyntacticDiagnostics(file: string): DiagnosticWithLocation[] { @@ -716,6 +719,10 @@ namespace ts.server { throw new Error("cleanupSemanticCache is not available through the server layer."); } + getSourceMapper(): never { + return notImplemented(); + } + dispose(): void { throw new Error("dispose is not available through the server layer."); } diff --git a/src/harness/documents.ts b/src/harness/documents.ts index 52773bf774a..a1c75784f85 100644 --- a/src/harness/documents.ts +++ b/src/harness/documents.ts @@ -148,7 +148,7 @@ namespace documents { public static fromUrl(url: string) { const match = SourceMap._dataURLRegExp.exec(url); - return match ? new SourceMap(/*mapFile*/ undefined, new Buffer(match[1], "base64").toString("utf8")) : undefined; + return match ? new SourceMap(/*mapFile*/ undefined, (Buffer.from ? Buffer.from(match[1], "base64") : new Buffer(match[1], "base64")).toString("utf8")) : undefined; } public static fromSource(text: string): SourceMap | undefined { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d748506cd3a..3465ef333a0 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1007,7 +1007,7 @@ namespace FourSlash { // If any of the expected values are undefined, assume that users don't // care about them. - if (replacementSpan && !TestState.textSpansEqual(replacementSpan, entry.replacementSpan)) { + if (replacementSpan && !ts.textSpansEqual(replacementSpan, entry.replacementSpan)) { return false; } else if (expectedText && text !== expectedText) { @@ -1644,7 +1644,7 @@ Actual: ${stringify(fullActual)}`); }); } - public baselineGetEmitOutput(insertResultsIntoVfs?: boolean) { + private getEmitFiles(): ReadonlyArray { // Find file to be emitted const emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on @@ -1661,12 +1661,29 @@ Actual: ${stringify(fullActual)}`); this.raiseError("No emitThisFile is specified in the test file"); } + return emitFiles; + } + + public verifyGetEmitOutput(expectedOutputFiles: ReadonlyArray): void { + const outputFiles = ts.flatMap(this.getEmitFiles(), e => this.languageService.getEmitOutput(e.fileName).outputFiles); + + assert.deepEqual(outputFiles.map(f => f.name), expectedOutputFiles); + + for (const { name, text } of outputFiles) { + const fromTestFile = this.getFileContent(name); + if (fromTestFile !== text) { + this.raiseError("Emit output is not as expected: " + showTextDiff(fromTestFile, text)); + } + } + } + + public baselineGetEmitOutput(): void { Harness.Baseline.runBaseline( - this.testData.globalOptions[MetadataOptionNames.baselineFile], + ts.Debug.assertDefined(this.testData.globalOptions[MetadataOptionNames.baselineFile]), () => { let resultString = ""; // Loop through all the emittedFiles and emit them one by one - emitFiles.forEach(emitFile => { + for (const emitFile of this.getEmitFiles()) { const emitOutput = this.languageService.getEmitOutput(emitFile.fileName); // Print emitOutputStatus in readable format resultString += "EmitSkipped: " + emitOutput.emitSkipped + Harness.IO.newLine(); @@ -1692,13 +1709,10 @@ Actual: ${stringify(fullActual)}`); for (const outputFile of emitOutput.outputFiles) { const fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); - resultString = resultString + fileName + outputFile.text; - if (insertResultsIntoVfs) { - this.languageServiceAdapterHost.addScript(ts.getNormalizedAbsolutePath(outputFile.name, "/"), outputFile.text, /*isRootFile*/ true); - } + resultString = resultString + Harness.IO.newLine() + fileName + outputFile.text; } resultString += Harness.IO.newLine(); - }); + } return resultString; }); @@ -2137,11 +2151,10 @@ Actual: ${stringify(fullActual)}`); this.raiseError("verifyRangesInImplementationList failed - expected to find at least one implementation location but got 0"); } - const duplicate = findDuplicatedElement(implementations, implementationsAreEqual); + const duplicate = findDuplicatedElement(implementations, ts.documentSpansEqual); if (duplicate) { const { textSpan, fileName } = duplicate; - const end = textSpan.start + textSpan.length; - this.raiseError(`Duplicate implementations returned for range (${textSpan.start}, ${end}) in ${fileName}`); + this.raiseError(`Duplicate implementations returned for range (${textSpan.start}, ${ts.textSpanEnd(textSpan)}) in ${fileName}`); } const ranges = this.getRanges(); @@ -2208,10 +2221,6 @@ Actual: ${stringify(fullActual)}`); this.raiseError(error); } - function implementationsAreEqual(a: ImplementationLocationInformation, b: ImplementationLocationInformation) { - return a.fileName === b.fileName && TestState.textSpansEqual(a.textSpan, b.textSpan); - } - function displayPartIsEqualTo(a: ts.SymbolDisplayPart, b: ts.SymbolDisplayPart): boolean { return a.kind === b.kind && a.text === b.text; } @@ -3260,7 +3269,7 @@ Actual: ${stringify(fullActual)}`); if (spanIndex !== undefined) { const span = this.getTextSpanForRangeAtIndex(spanIndex); - assert.isTrue(TestState.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + stringify(entryId))); + assert.isTrue(ts.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + stringify(entryId))); } eq(item.hasAction, hasAction, "hasAction"); @@ -3346,10 +3355,6 @@ Actual: ${stringify(fullActual)}`); this.cancellationToken.resetCancelled(); } - private static textSpansEqual(a: ts.TextSpan | undefined, b: ts.TextSpan | undefined): boolean { - return !!a && !!b && a.start === b.start && a.length === b.length; - } - public getEditsForFileRename({ oldPath, newPath, newFileContents }: FourSlashInterface.GetEditsForFileRenameOptions): void { const test = (fileContents: { readonly [fileName: string]: string }, description: string): void => { const changes = this.languageService.getEditsForFileRename(oldPath, newPath, this.formatCodeSettings, ts.emptyOptions); @@ -3551,8 +3556,13 @@ ${code} function getNonFileNameOptionInObject(optionObject: { [s: string]: string }): string | undefined { for (const option in optionObject) { - if (option !== MetadataOptionNames.fileName) { - return option; + switch (option) { + case MetadataOptionNames.fileName: + case MetadataOptionNames.baselineFile: + case MetadataOptionNames.emitThisFile: + break; + default: + return option; } } return undefined; @@ -4270,8 +4280,12 @@ namespace FourSlashInterface { this.state.baselineCurrentFileNameOrDottedNameSpans(); } - public baselineGetEmitOutput(insertResultsIntoVfs?: boolean) { - this.state.baselineGetEmitOutput(insertResultsIntoVfs); + public getEmitOutput(expectedOutputFiles: ReadonlyArray): void { + this.state.verifyGetEmitOutput(expectedOutputFiles); + } + + public baselineGetEmitOutput() { + this.state.baselineGetEmitOutput(); } public baselineQuickInfo() { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 4376848e176..761be1ae999 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -560,6 +560,9 @@ namespace Harness.LanguageService { getSourceFile(): ts.SourceFile { throw new Error("SourceFile can not be marshaled across the shim layer."); } + getSourceMapper(): never { + return ts.notImplemented(); + } dispose(): void { this.shim.dispose({}); } } @@ -707,7 +710,9 @@ namespace Harness.LanguageService { return ts.sys.getEnvironmentVariable(name); } - readDirectory() { return ts.notImplemented(); } + readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[] { + return this.host.readDirectory(path, extensions, exclude, include, depth); + } watchFile(): ts.FileWatcher { return { close: ts.noop }; diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index 22f0659690b..a1aa07f8733 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -305,7 +305,8 @@ namespace Harness.SourceMapRecorder { } SourceMapSpanWriter.initializeSourceMapSpanWriter(sourceMapRecorder, sourceMapData, currentFile); - for (const decodedSourceMapping of sourceMapData.sourceMapDecodedMappings) { + const mapper = ts.sourcemaps.decodeMappings({ mappings: sourceMapData.sourceMapMappings, sources: sourceMapData.sourceMapSources }); + for (let { value: decodedSourceMapping, done } = mapper.next(); !done; { value: decodedSourceMapping, done } = mapper.next()) { const currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex])!; if (currentSourceFile !== prevSourceFile) { SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text); diff --git a/src/harness/utils.ts b/src/harness/utils.ts index d7e113c45fb..4650badadaf 100644 --- a/src/harness/utils.ts +++ b/src/harness/utils.ts @@ -63,10 +63,6 @@ namespace utils { return indentation; } - export function toUtf8(text: string): string { - return new Buffer(text).toString("utf8"); - } - export function getByteOrderMarkLength(text: string): number { if (text.length >= 1) { const ch0 = text.charCodeAt(0); diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index d56bc37cc21..8f3fbe1ad2d 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -78,7 +78,9 @@ interface Array {}` } export interface SymLink { + /** Location of the symlink. */ path: string; + /** Relative path to the real file. */ symLink: string; } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 9e86ef849a5..568a1d1fb60 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -851,7 +851,7 @@ namespace ts.server { configFileExistenceInfo.exists = false; this.removeProject(project); - // Reload the configured projects for the open files in the map as they are affectected by this config file + // Reload the configured projects for the open files in the map as they are affected by this config file // Since the configured project was deleted, we want to reload projects for all the open files including files // that are not root of the inferred project this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, ConfigFileWatcherStatus.ReloadingFiles); @@ -1171,7 +1171,7 @@ namespace ts.server { */ private stopWatchingConfigFilesForClosedScriptInfo(info: ScriptInfo) { Debug.assert(!info.isScriptOpen()); - this.forEachConfigFileLocation(info, (configFileName, canonicalConfigFilePath) => { + this.forEachConfigFileLocation(info, /*infoShouldBeOpen*/ true, (configFileName, canonicalConfigFilePath) => { const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo) { const infoIsRootOfInferredProject = configFileExistenceInfo.openFilesImpactedByConfigFile.get(info.path); @@ -1205,7 +1205,7 @@ namespace ts.server { /* @internal */ startWatchingConfigFilesForInferredProjectRoot(info: ScriptInfo) { Debug.assert(info.isScriptOpen()); - this.forEachConfigFileLocation(info, (configFileName, canonicalConfigFilePath) => { + this.forEachConfigFileLocation(info, /*infoShouldBeOpen*/ true, (configFileName, canonicalConfigFilePath) => { let configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (!configFileExistenceInfo) { // Create the cache @@ -1233,7 +1233,7 @@ namespace ts.server { */ /* @internal */ stopWatchingConfigFilesForInferredProjectRoot(info: ScriptInfo) { - this.forEachConfigFileLocation(info, (configFileName, canonicalConfigFilePath) => { + this.forEachConfigFileLocation(info, /*infoShouldBeOpen*/ true, (configFileName, canonicalConfigFilePath) => { const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo && configFileExistenceInfo.openFilesImpactedByConfigFile.has(info.path)) { Debug.assert(info.isScriptOpen()); @@ -1256,18 +1256,18 @@ namespace ts.server { * The server must start searching from the directory containing * the newly opened file. */ - private forEachConfigFileLocation(info: ScriptInfo, action: (configFileName: NormalizedPath, canonicalConfigFilePath: string) => boolean | void) { + private forEachConfigFileLocation(info: ScriptInfo, infoShouldBeOpen: boolean, action: (configFileName: NormalizedPath, canonicalConfigFilePath: string) => boolean | void) { if (this.syntaxOnly) { return undefined; } - Debug.assert(this.openFiles.has(info.path)); + Debug.assert(!infoShouldBeOpen || this.openFiles.has(info.path)); const projectRootPath = this.openFiles.get(info.path); let searchPath = asNormalizedPath(getDirectoryPath(info.fileName)); const isSearchPathInProjectRoot = () => containsPath(projectRootPath!, searchPath, this.currentDirectory, !this.host.useCaseSensitiveFileNames); - // If projectRootPath doesnt contain info.path, then do normal search for config file + // If projectRootPath doesn't contain info.path, then do normal search for config file const anySearchPathOk = !projectRootPath || !isSearchPathInProjectRoot(); do { const canonicalSearchPath = normalizedPathToPath(searchPath, this.currentDirectory, this.toCanonicalFileName); @@ -1301,13 +1301,11 @@ namespace ts.server { * The server must start searching from the directory containing * the newly opened file. */ - private getConfigFileNameForFile(info: ScriptInfo) { - Debug.assert(info.isScriptOpen()); + private getConfigFileNameForFile(info: ScriptInfo, infoShouldBeOpen: boolean) { + if (infoShouldBeOpen) Debug.assert(info.isScriptOpen()); this.logger.info(`Search path: ${getDirectoryPath(info.fileName)}`); - const configFileName = this.forEachConfigFileLocation(info, - (configFileName, canonicalConfigFilePath) => - this.configFileExists(configFileName, canonicalConfigFilePath, info) - ); + const configFileName = this.forEachConfigFileLocation(info, infoShouldBeOpen, (configFileName, canonicalConfigFilePath) => + this.configFileExists(configFileName, canonicalConfigFilePath, info)); if (configFileName) { this.logger.info(`For info: ${info.fileName} :: Config file name: ${configFileName}`); } @@ -1840,13 +1838,11 @@ namespace ts.server { } } - /*@internal*/ - getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined, hostToQueryFileExistsOn: DirectoryStructureHost | undefined) { + private getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined, hostToQueryFileExistsOn: DirectoryStructureHost | undefined) { return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent, hostToQueryFileExistsOn); } - /*@internal*/ - getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, fileContent: string | undefined, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined) { + private getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, fileContent: string | undefined, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined) { return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ true, fileContent, scriptKind, hasMixedContent); } @@ -1989,7 +1985,7 @@ namespace ts.server { // we first detect if there is already a configured project created for it: if so, // we re- read the tsconfig file content and update the project only if we havent already done so // otherwise we create a new one. - const configFileName = this.getConfigFileNameForFile(info); + const configFileName = this.getConfigFileNameForFile(info, /*infoShouldBeOpen*/ true); if (configFileName) { const project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { @@ -2077,6 +2073,24 @@ namespace ts.server { return this.openClientFileWithNormalizedPath(toNormalizedPath(fileName), fileContent, scriptKind, /*hasMixedContent*/ false, projectRootPath ? toNormalizedPath(projectRootPath) : undefined); } + /** @internal */ + getProjectForFileWithoutOpening(fileName: NormalizedPath): { readonly scriptInfo: ScriptInfo, readonly projects: ReadonlyArray } | undefined { + const scriptInfo = this.filenameToScriptInfo.get(fileName) || + this.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName, this.currentDirectory, /*fileContent*/ undefined, /*scriptKind*/ undefined, /*hasMixedContent*/ undefined); + if (!scriptInfo) return undefined; + if (scriptInfo.containingProjects.length) { + return { scriptInfo, projects: scriptInfo.containingProjects }; + } + const configFileName = this.getConfigFileNameForFile(scriptInfo, /*infoShouldBeOpen*/ false); + const project = configFileName === undefined ? undefined : this.findConfiguredProjectByProjectName(configFileName) || this.createConfiguredProject(configFileName); + return project && project.containsScriptInfo(scriptInfo) ? { scriptInfo, projects: [project] } : undefined; + } + + /** @internal */ + fileExists(fileName: NormalizedPath): boolean { + return this.filenameToScriptInfo.has(fileName) || this.host.fileExists(fileName); + } + private findExternalProjectContainingOpenScriptInfo(info: ScriptInfo): ExternalProject | undefined { return find(this.externalProjects, proj => { // Ensure project structure is up-to-date to check if info is present in external project @@ -2090,10 +2104,11 @@ namespace ts.server { let configFileErrors: ReadonlyArray | undefined; const info = this.getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName, projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory, fileContent, scriptKind, hasMixedContent)!; // TODO: GH#18217 + this.openFiles.set(info.path, projectRootPath); let project: ConfiguredProject | ExternalProject | undefined = this.findExternalProjectContainingOpenScriptInfo(info); if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization - configFileName = this.getConfigFileNameForFile(info); + configFileName = this.getConfigFileNameForFile(info, /*infoShouldBeOpen*/ true); if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { diff --git a/src/server/project.ts b/src/server/project.ts index 343c4a2e97d..08b08eae04c 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -271,8 +271,8 @@ namespace ts.server { return this.projectStateVersion.toString(); } - getProjectReferences(): ReadonlyArray | undefined { - return undefined; + getProjectReferences(): ReadonlyArray { + return emptyArray; } getScriptFileNames() { @@ -461,6 +461,11 @@ namespace ts.server { return this.languageService; } + /** @internal */ + getSourceMapper(): SourceMapper { + return this.getLanguageService().getSourceMapper(); + } + private shouldEmitFile(scriptInfo: ScriptInfo) { return scriptInfo && !scriptInfo.isDynamicOrHasMixedContent(); } @@ -1351,8 +1356,8 @@ namespace ts.server { return asNormalizedPath(this.getProjectName()); } - getProjectReferences(): ReadonlyArray | undefined { - return this.projectReferences; + getProjectReferences(): ReadonlyArray { + return this.projectReferences || emptyArray; } updateReferences(refs: ReadonlyArray | undefined) { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index b3238fd9f7f..2e5218f754d 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -34,6 +34,8 @@ namespace ts.server.protocol { Implementation = "implementation", /* @internal */ ImplementationFull = "implementation-full", + /* @internal */ + EmitOutput = "emit-output", Exit = "exit", Format = "format", Formatonkey = "formatonkey", @@ -794,6 +796,21 @@ namespace ts.server.protocol { command: CommandTypes.Definition; } + export interface DefinitionAndBoundSpanRequest extends FileLocationRequest { + readonly command: CommandTypes.DefinitionAndBoundSpan; + } + + export interface DefinitionAndBoundSpanResponse extends Response { + readonly body: DefinitionInfoAndBoundSpan; + } + + /** @internal */ + export interface EmitOutputRequest extends FileRequest {} + /** @internal */ + export interface EmitOutputResponse extends Response { + readonly body: EmitOutput; + } + /** * Go to type request; value of command field is * "typeDefinition". Return response giving the file locations that @@ -1056,6 +1073,17 @@ namespace ts.server.protocol { arguments: RenameRequestArgs; } + /* @internal */ + export interface RenameFullRequest extends FileLocationRequest { + readonly command: CommandTypes.RenameLocationsFull; + readonly arguments: RenameRequestArgs; + } + + /* @internal */ + export interface RenameFullResponse extends Response { + readonly body: ReadonlyArray; + } + /** * Information about the item to be renamed. */ @@ -1246,7 +1274,7 @@ namespace ts.server.protocol { /* @internal */ export interface ProjectFiles { /** - * Information abount project verison + * Information about project verison */ info?: ProjectVersionInfo; /** diff --git a/src/server/session.ts b/src/server/session.ts index ed46cdd39b4..1f22c7baa71 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -42,31 +42,6 @@ namespace ts.server { return false; } - interface FileStart { - file: string; - start: protocol.Location; - } - - function compareNumber(a: number, b: number) { - return a - b; - } - - function compareFileStart(a: FileStart, b: FileStart) { - if (a.file < b.file) { - return -1; - } - else if (a.file === b.file) { - const n = compareNumber(a.start.line, b.start.line); - if (n === 0) { - return compareNumber(a.start.offset, b.start.offset); - } - else return n; - } - else { - return 1; - } - } - function formatDiag(fileName: NormalizedPath, project: Project, diag: Diagnostic): protocol.Diagnostic { const scriptInfo = project.getScriptInfoForNormalizedPath(fileName)!; // TODO: GH#18217 return { @@ -279,8 +254,8 @@ namespace ts.server { } type Projects = ReadonlyArray | { - projects: ReadonlyArray; - symLinkedProjects: MultiMap; + readonly projects: ReadonlyArray; + readonly symLinkedProjects: MultiMap; }; function isProjectsArray(projects: Projects): projects is ReadonlyArray { @@ -290,7 +265,14 @@ namespace ts.server { /** * This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project. */ - function combineProjectOutput(defaultValue: T, getValue: (path: Path) => T, projects: Projects, action: (project: Project, value: T) => ReadonlyArray | U | undefined, comparer?: (a: U, b: U) => number, areEqual?: (a: U, b: U) => boolean) { + function combineProjectOutput( + defaultValue: T, + getValue: (path: Path) => T, + projects: Projects, + action: (project: Project, value: T) => ReadonlyArray | U | undefined, + comparer?: (a: U, b: U) => number, + areEqual?: (a: U, b: U) => boolean, + ): U[] { const outputs = flatMap(isProjectsArray(projects) ? projects : projects.projects, project => action(project, defaultValue)); if (!isProjectsArray(projects) && projects.symLinkedProjects) { projects.symLinkedProjects.forEach((projects, path) => { @@ -304,6 +286,150 @@ namespace ts.server { : deduplicate(outputs, areEqual); } + function combineProjectOutputWhileOpeningReferencedProjects( + projects: Projects, + projectService: ProjectService, + action: (project: Project) => ReadonlyArray, + getLocation: (t: T) => sourcemaps.SourceMappableLocation, + resultsEqual: (a: T, b: T) => boolean, + ): T[] { + const outputs: T[] = []; + combineProjectOutputWorker(projects, undefined, projectService, ({ project }, tryAddToTodo) => { + for (const output of action(project)) { + if (!contains(outputs, output, resultsEqual) && !tryAddToTodo(project, getLocation(output))) { + outputs.push(output); + } + } + }); + return outputs; + } + + function combineProjectOutputForRenameLocations(projects: Projects, initialLocation: sourcemaps.SourceMappableLocation, projectService: ProjectService, findInStrings: boolean, findInComments: boolean): ReadonlyArray { + const outputs: RenameLocation[] = []; + + combineProjectOutputWorker(projects, initialLocation, projectService, ({ project, location }, tryAddToTodo) => { + for (const output of project.getLanguageService().findRenameLocations(location.fileName, location.position, findInStrings, findInComments) || emptyArray) { + if (!contains(outputs, output, documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) { + outputs.push(output); + } + } + }); + + return outputs; + } + + function combineProjectOutputForReferences(projects: Projects, initialLocation: sourcemaps.SourceMappableLocation, projectService: ProjectService): ReadonlyArray { + const outputs: ReferencedSymbol[] = []; + + combineProjectOutputWorker(projects, initialLocation, projectService, ({ project, location }, tryAddToTodo) => { + for (const outputReferencedSymbol of project.getLanguageService().findReferences(location.fileName, location.position) || emptyArray) { + let symbolToAddTo = find(outputs, o => documentSpansEqual(o.definition, outputReferencedSymbol.definition)); + if (!symbolToAddTo) { + symbolToAddTo = { definition: outputReferencedSymbol.definition, references: [] }; + outputs.push(symbolToAddTo); + } + + for (const ref of outputReferencedSymbol.references) { + if (!contains(symbolToAddTo.references, ref, documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(ref))) { + symbolToAddTo.references.push(ref); + } + } + } + }); + + return outputs.filter(o => o.references.length !== 0); + } + + interface ProjectAndLocation { + readonly project: Project; + readonly location: sourcemaps.SourceMappableLocation; + } + + interface ToDoAndSeenProjects { + readonly toDo: ProjectAndLocation[]; + readonly seenProjects: Map; + } + + function combineProjectOutputWorker( + projects: Projects, + initialLocation: sourcemaps.SourceMappableLocation, + projectService: ProjectService, + cb: (where: ProjectAndLocation, getMappedLocation: (project: Project, location: sourcemaps.SourceMappableLocation) => boolean) => void, + ): void { + let toDoAndSeenProjects: ToDoAndSeenProjects | undefined; + for (const project of isProjectsArray(projects) ? projects : projects.projects) { + toDoAndSeenProjects = callbackProjectAndLocation(projects, { project, location: initialLocation }, projectService, toDoAndSeenProjects, cb); + } + if (!isArray(projects) && projects.symLinkedProjects) { + projects.symLinkedProjects.forEach((symlinkedProjects, path) => { + for (const project of symlinkedProjects) { + toDoAndSeenProjects = callbackProjectAndLocation(projects, { project, location: { fileName: path, position: initialLocation.position } }, projectService, toDoAndSeenProjects, cb); + } + }); + } + + while (toDoAndSeenProjects && toDoAndSeenProjects.toDo.length) { + toDoAndSeenProjects = callbackProjectAndLocation(projects, Debug.assertDefined(toDoAndSeenProjects.toDo.pop()), projectService, toDoAndSeenProjects, cb); + } + } + + function callbackProjectAndLocation( + originalProjects: Projects, // For lazily populating seenProjects + projectAndLocation: ProjectAndLocation, + projectService: ProjectService, + toDoAndSeenProjects: ToDoAndSeenProjects | undefined, + cb: (where: ProjectAndLocation, getMappedLocation: (project: Project, location: sourcemaps.SourceMappableLocation) => boolean) => void, + ): ToDoAndSeenProjects | undefined { + if (projectAndLocation.project.getCancellationToken().isCancellationRequested()) return undefined; // Skip rest of toDo if cancelled + cb(projectAndLocation, (project, location) => { + const originalLocation = project.getSourceMapper().tryGetOriginalLocation(location); + if (!originalLocation) return false; + const originalProjectAndScriptInfo = projectService.getProjectForFileWithoutOpening(toNormalizedPath(originalLocation.fileName)); + if (!originalProjectAndScriptInfo) return false; + + if (originalProjectAndScriptInfo) { + if (toDoAndSeenProjects === undefined) { + toDoAndSeenProjects = { toDo: [], seenProjects: createMap() }; + for (const project of isProjectsArray(originalProjects) ? originalProjects : originalProjects.projects) { + toDoAndSeenProjects.seenProjects.set(project.projectName, true); + } + if (!isArray(originalProjects) && originalProjects.symLinkedProjects) { + originalProjects.symLinkedProjects.forEach(symlinkedProjects => { + for (const project of symlinkedProjects) { + toDoAndSeenProjects!.seenProjects.set(project.projectName, true); + } + }); + } + } + + for (const project of originalProjectAndScriptInfo.projects) { + addToTodo({ project, location: originalLocation }, toDoAndSeenProjects); + } + const symlinkedProjectsMap = projectService.getSymlinkedProjects(originalProjectAndScriptInfo.scriptInfo); + if (symlinkedProjectsMap) { + symlinkedProjectsMap.forEach((symlinkedProjects) => { + for (const symlinkedProject of symlinkedProjects) addToTodo({ project: symlinkedProject, location: originalLocation }, toDoAndSeenProjects!); + }); + } + } + return true; + }); + return toDoAndSeenProjects; + } + + function addToTodo(projectAndLocation: ProjectAndLocation, { seenProjects, toDo }: ToDoAndSeenProjects): void { + if (addToSeen(seenProjects, projectAndLocation.project.projectName)) toDo.push(projectAndLocation); + } + + function documentSpanLocation({ fileName, textSpan }: DocumentSpan): sourcemaps.SourceMappableLocation { + return { fileName, position: textSpan.start }; + } + + function getMappedLocation(location: sourcemaps.SourceMappableLocation, projectService: ProjectService, project: Project): sourcemaps.SourceMappableLocation | undefined { + const mapsTo = project.getSourceMapper().tryGetOriginalLocation(location); + return mapsTo && projectService.fileExists(toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined; + } + export interface SessionOptions { host: ServerHost; cancellationToken: ServerCancellationToken; @@ -690,46 +816,64 @@ namespace ts.server { private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); + const definitions = this.mapDefinitionInfoLocations(project.getLanguageService().getDefinitionAtPosition(file, position) || emptyArray, project); + return simplifiedResult ? this.mapDefinitionInfo(definitions, project) : definitions.map(Session.mapToOriginalLocation); + } - const definitions = project.getLanguageService().getDefinitionAtPosition(file, position); - if (!definitions) { - return emptyArray; - } - - if (simplifiedResult) { - return this.mapDefinitionInfo(definitions, project); - } - - return definitions.map(Session.mapToOriginalLocation); + private mapDefinitionInfoLocations(definitions: ReadonlyArray, project: Project): ReadonlyArray { + return definitions.map((info): DefinitionInfo => { + const newLoc = getMappedLocation(documentSpanLocation(info), this.projectService, project); + return !newLoc ? info : { + containerKind: info.containerKind, + containerName: info.containerName, + fileName: newLoc.fileName, + kind: info.kind, + name: info.name, + textSpan: { + start: newLoc.position, + length: info.textSpan.length + }, + originalFileName: info.fileName, + originalTextSpan: info.textSpan, + }; + }); } private getDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - const scriptInfo = project.getScriptInfo(file)!; + const scriptInfo = Debug.assertDefined(project.getScriptInfo(file)); - const definitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position); + const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position); - if (!definitionAndBoundSpan || !definitionAndBoundSpan.definitions) { + if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) { return { definitions: emptyArray, textSpan: undefined! // TODO: GH#18217 }; } + const definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project); + const { textSpan } = unmappedDefinitionAndBoundSpan; + if (simplifiedResult) { return { - definitions: this.mapDefinitionInfo(definitionAndBoundSpan.definitions, project), - textSpan: this.toLocationTextSpan(definitionAndBoundSpan.textSpan, scriptInfo) + definitions: this.mapDefinitionInfo(definitions, project), + textSpan: this.toLocationTextSpan(textSpan, scriptInfo) }; } return { - ...definitionAndBoundSpan, - definitions: definitionAndBoundSpan.definitions.map(Session.mapToOriginalLocation) + definitions: definitions.map(Session.mapToOriginalLocation), + textSpan, }; } + private getEmitOutput(args: protocol.FileRequestArgs): EmitOutput { + const { file, project } = this.getFileAndProject(args); + return project.getLanguageService().getEmitOutput(file); + } + private mapDefinitionInfo(definitions: ReadonlyArray, project: Project): ReadonlyArray { return definitions.map(def => this.toFileSpan(def.fileName, def.textSpan, project)); } @@ -771,21 +915,31 @@ namespace ts.server { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - const definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); - if (!definitions) { - return emptyArray; - } - + const definitions = this.mapDefinitionInfoLocations(project.getLanguageService().getTypeDefinitionAtPosition(file, position) || emptyArray, project); return this.mapDefinitionInfo(definitions, project); } + private mapImplementationLocations(implementations: ReadonlyArray, project: Project): ReadonlyArray { + return implementations.map((info): ImplementationLocation => { + const newLoc = getMappedLocation(documentSpanLocation(info), this.projectService, project); + return !newLoc ? info : { + fileName: newLoc.fileName, + kind: info.kind, + displayParts: info.displayParts, + textSpan: { + start: newLoc.position, + length: info.textSpan.length + }, + originalFileName: info.fileName, + originalTextSpan: info.textSpan, + }; + }); + } + private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - const implementations = project.getLanguageService().getImplementationAtPosition(file, position); - if (!implementations) { - return emptyArray; - } + const implementations = this.mapImplementationLocations(project.getLanguageService().getImplementationAtPosition(file, position) || emptyArray, project); if (simplifiedResult) { return implementations.map(({ fileName, textSpan }) => this.toFileSpan(fileName, textSpan, project)); } @@ -948,179 +1102,59 @@ namespace ts.server { return info.getDefaultProject(); } - private getRenameLocations(args: protocol.RenameRequestArgs, simplifiedResult: boolean): protocol.RenameResponseBody | ReadonlyArray | undefined { + private getRenameLocations(args: protocol.RenameRequestArgs, simplifiedResult: boolean): protocol.RenameResponseBody | ReadonlyArray { const file = toNormalizedPath(args.file); const position = this.getPositionInFile(args, file); const projects = this.getProjects(args); - if (simplifiedResult) { - const defaultProject = this.getDefaultProject(args); - // The rename info should be the same for every project - const renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } + const locations = combineProjectOutputForRenameLocations(projects, { fileName: args.file, position }, this.projectService, !!args.findInStrings, !!args.findInComments); + if (!simplifiedResult) return locations; - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: emptyArray - }; - } + const defaultProject = this.getDefaultProject(args); + const renameInfo = Session.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position)); + return { info: renameInfo, locs: this.toSpanGroups(locations) }; + } - const fileSpans = combineProjectOutput( - file, - path => this.projectService.getScriptInfoForPath(path)!.fileName, - projects, - (project, file) => { - const renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings!, args.findInComments!); - if (!renameLocations) { - return emptyArray; - } + // strips 'triggerSpan' + private static mapRenameInfo({ canRename, localizedErrorMessage, displayName, fullDisplayName, kind, kindModifiers }: RenameInfo): protocol.RenameInfo { + return { canRename, localizedErrorMessage, displayName, fullDisplayName, kind, kindModifiers }; + } - return renameLocations.map(location => { - const locationScriptInfo = project.getScriptInfo(location.fileName)!; - return { - file: location.fileName, - start: locationScriptInfo.positionToLineOffset(location.textSpan.start), - end: locationScriptInfo.positionToLineOffset(textSpanEnd(location.textSpan)), - }; - }); - }, - compareRenameLocation, - (a, b) => a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset - ); - - const locs: protocol.SpanGroup[] = []; - for (const cur of fileSpans) { - let curFileAccum: protocol.SpanGroup | undefined; - if (locs.length > 0) { - curFileAccum = locs[locs.length - 1]; - if (curFileAccum.file !== cur.file) { - curFileAccum = undefined; - } - } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - locs.push(curFileAccum); - } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - } - - return { info: renameInfo, locs }; - } - else { - return combineProjectOutput( - file, - path => this.projectService.getScriptInfoForPath(path)!.fileName, - projects, - (p, file) => p.getLanguageService().findRenameLocations(file, position, args.findInStrings!, args.findInComments!), - /*comparer*/ undefined, - renameLocationIsEqualTo - ); - } - - function renameLocationIsEqualTo(a: RenameLocation, b: RenameLocation) { - if (a === b) { - return true; - } - if (!a || !b) { - return false; - } - return a.fileName === b.fileName && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; - } - - function compareRenameLocation(a: protocol.FileSpan, b: protocol.FileSpan) { - if (a.file < b.file) { - return -1; - } - else if (a.file > b.file) { - return 1; - } - else { - // reverse sort assuming no overlap - if (a.start.line < b.start.line) { - return 1; - } - else if (a.start.line > b.start.line) { - return -1; - } - else { - return b.start.offset - a.start.offset; - } - } + private toSpanGroups(locations: ReadonlyArray): ReadonlyArray { + const map = createMap(); + for (const { fileName, textSpan } of locations) { + let group = map.get(fileName); + if (!group) map.set(fileName, group = { file: fileName, locs: [] }); + group.locs.push(this.toLocationTextSpan(textSpan, Debug.assertDefined(this.projectService.getScriptInfo(fileName)))); } + return arrayFrom(map.values()); } private getReferences(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.ReferencesResponseBody | undefined | ReadonlyArray { const file = toNormalizedPath(args.file); const projects = this.getProjects(args); + const position = this.getPositionInFile(args, file); + const references = combineProjectOutputForReferences(projects, { fileName: args.file, position }, this.projectService); - const defaultProject = this.getDefaultProject(args); - const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!; - const position = this.getPosition(args, scriptInfo); if (simplifiedResult) { + const defaultProject = this.getDefaultProject(args); + const scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file)!; const nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - const displayString = nameInfo ? displayPartsToString(nameInfo.displayParts) : ""; + const symbolDisplayString = nameInfo ? displayPartsToString(nameInfo.displayParts) : ""; const nameSpan = nameInfo && nameInfo.textSpan; - const nameColStart = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0; - const nameText = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : ""; - const refs = combineProjectOutput( - file, - path => this.projectService.getScriptInfoForPath(path)!.fileName, - projects, - (project, file) => { - const references = project.getLanguageService().getReferencesAtPosition(file, position); - if (!references) { - return emptyArray; - } - - return references.map(ref => { - const refScriptInfo = project.getScriptInfo(ref.fileName)!; - const start = refScriptInfo.positionToLineOffset(ref.textSpan.start); - const refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); - const lineText = refScriptInfo.getSnapshot().getText(refLineSpan.start, textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start, - lineText, - end: refScriptInfo.positionToLineOffset(textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess, - isDefinition: ref.isDefinition - }; - }); - }, - compareFileStart, - areReferencesResponseItemsForTheSameLocation - ); - - return { - refs, - symbolName: nameText, - symbolStartOffset: nameColStart, - symbolDisplayString: displayString - }; + const symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0; + const symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : ""; + const refs: protocol.ReferencesResponseItem[] = flatMap(references, referencedSymbol => + referencedSymbol.references.map(({ fileName, textSpan, isWriteAccess, isDefinition }): protocol.ReferencesResponseItem => { + const scriptInfo = Debug.assertDefined(this.projectService.getScriptInfo(fileName)); + const lineText = scriptInfo.getSnapshot().getText(textSpan.start, textSpanEnd(textSpan)); + return { ...toFileSpan(fileName, textSpan, scriptInfo), lineText, isWriteAccess, isDefinition }; + })); + const result: protocol.ReferencesResponseBody = { refs, symbolName, symbolStartOffset, symbolDisplayString }; + return result; } else { - return combineProjectOutput( - file, - path => this.projectService.getScriptInfoForPath(path)!.fileName, - projects, - (project, file) => project.getLanguageService().findReferences(file, position), - /*comparer*/ undefined, - equateValues - ); - } - - function areReferencesResponseItemsForTheSameLocation(a: protocol.ReferencesResponseItem, b: protocol.ReferencesResponseItem) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; - } - return false; + return references; } } @@ -1568,63 +1602,45 @@ namespace ts.server { } private getNavigateToItems(args: protocol.NavtoRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { - const projects = this.getProjects(args); + const full = this.getFullNavigateToItems(args); + return !simplifiedResult ? full : full.map((navItem) => { + const { file, project } = this.getFileAndProject({ file: navItem.fileName }); + const scriptInfo = project.getScriptInfo(file)!; + const bakedItem: protocol.NavtoItem = { + name: navItem.name, + kind: navItem.kind, + isCaseSensitive: navItem.isCaseSensitive, + matchKind: navItem.matchKind, + file: navItem.fileName, + start: scriptInfo.positionToLineOffset(navItem.textSpan.start), + end: scriptInfo.positionToLineOffset(textSpanEnd(navItem.textSpan)) + }; + if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { + bakedItem.kindModifiers = navItem.kindModifiers; + } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + } - const fileName = args.currentFileOnly ? args.file && normalizeSlashes(args.file) : undefined; - if (simplifiedResult) { - return combineProjectOutput( - fileName, - () => undefined, - projects, - (project, file) => { - if (fileName && !file) { - return undefined; - } - - const navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, /*excludeDts*/ project.isNonTsProject()); - if (!navItems) { - return emptyArray; - } - - return navItems.map((navItem) => { - const scriptInfo = project.getScriptInfo(navItem.fileName)!; - const bakedItem: protocol.NavtoItem = { - name: navItem.name, - kind: navItem.kind, - isCaseSensitive: navItem.isCaseSensitive, - matchKind: navItem.matchKind, - file: navItem.fileName, - start: scriptInfo.positionToLineOffset(navItem.textSpan.start), - end: scriptInfo.positionToLineOffset(textSpanEnd(navItem.textSpan)) - }; - if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }, - /*comparer*/ undefined, - areNavToItemsForTheSameLocation - ); + private getFullNavigateToItems(args: protocol.NavtoRequestArgs): ReadonlyArray { + const { currentFileOnly, searchValue, maxResultCount } = args; + if (currentFileOnly) { + const { file, project } = this.getFileAndProject(args); + return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file); } else { - return combineProjectOutput( - fileName, - () => undefined, - projects, - (project, file) => { - if (fileName && !file) { - return undefined; - } - return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, /*excludeDts*/ project.isNonTsProject()); - }, - /*comparer*/ undefined, + return combineProjectOutputWhileOpeningReferencedProjects( + this.getProjects(args), + this.projectService, + project => + project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()), + documentSpanLocation, navigateToItemIsEqualTo); } @@ -1646,15 +1662,6 @@ namespace ts.server { a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; } - - function areNavToItemsForTheSameLocation(a: protocol.NavtoItem, b: protocol.NavtoItem) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; - } - return false; - } } private getSupportedCodeFixes(): string[] { @@ -1976,6 +1983,9 @@ namespace ts.server { [CommandNames.DefinitionAndBoundSpanFull]: (request: protocol.DefinitionRequest) => { return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false)); }, + [CommandNames.EmitOutput]: (request: protocol.EmitOutputRequest) => { + return this.requiredResponse(this.getEmitOutput(request.arguments)); + }, [CommandNames.TypeDefinition]: (request: protocol.FileLocationRequest) => { return this.requiredResponse(this.getTypeDefinition(request.arguments)); }, @@ -1991,10 +2001,10 @@ namespace ts.server { [CommandNames.ReferencesFull]: (request: protocol.FileLocationRequest) => { return this.requiredResponse(this.getReferences(request.arguments, /*simplifiedResult*/ false)); }, - [CommandNames.Rename]: (request: protocol.Request) => { + [CommandNames.Rename]: (request: protocol.RenameRequest) => { return this.requiredResponse(this.getRenameLocations(request.arguments, /*simplifiedResult*/ true)); }, - [CommandNames.RenameLocationsFull]: (request: protocol.RenameRequest) => { + [CommandNames.RenameLocationsFull]: (request: protocol.RenameFullRequest) => { return this.requiredResponse(this.getRenameLocations(request.arguments, /*simplifiedResult*/ false)); }, [CommandNames.RenameInfoFull]: (request: protocol.FileLocationRequest) => { @@ -2332,6 +2342,10 @@ namespace ts.server { readonly project: Project; } + function toFileSpan(fileName: string, textSpan: TextSpan, scriptInfo: ScriptInfo): protocol.FileSpan { + return { file: fileName, start: scriptInfo.positionToLineOffset(textSpan.start), end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)) }; + } + function mapTextChangesToCodeEdits(textChanges: FileTextChanges, sourceFile: SourceFile | undefined): protocol.FileCodeEdits { Debug.assert(!!textChanges.isNewFile === !sourceFile); if (sourceFile) { diff --git a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts index b558a270dec..b382b9a2f05 100644 --- a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts +++ b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts @@ -2,7 +2,8 @@ namespace ts.codefix { const fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof"; const fixId = fixIdAddMissingTypeof; - const errorCodes = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code]; + const errorCodes = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code]; + registerCodeFix({ errorCodes, getCodeActions: context => { diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 8876a26cfa1..a745ef02fd4 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -188,7 +188,7 @@ namespace ts.codefix { const useNamespace = tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker); const addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. - const addImport = addToExisting ? [addToExisting] : getCodeActionsForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); + const addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); return [...(useNamespace ? [useNamespace] : emptyArray), ...addImport]; } @@ -261,7 +261,7 @@ namespace ts.codefix { return flatten(choicesForEachExportingModule.sort((a, b) => first(a).moduleSpecifier.length - first(b).moduleSpecifier.length)); } - function getCodeActionsForAddImport( + function getFixesForAddImport( exportInfos: ReadonlyArray, existingImports: ReadonlyArray, program: Program, @@ -376,13 +376,9 @@ namespace ts.codefix { // check the default export const defaultExport = checker.tryGetMemberInModuleExports(InternalSymbolName.Default, moduleSymbol); if (defaultExport) { - const localSymbol = getLocalSymbolForExportDefault(defaultExport); - if (( - localSymbol && localSymbol.escapedName === symbolName || - getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target!) === symbolName - ) && symbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { - addSymbol(moduleSymbol, localSymbol || defaultExport, ImportKind.Default); + const info = getDefaultExportInfo(defaultExport, moduleSymbol, program); + if (info && info.name === symbolName && symbolHasMeaning(info.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultExport, ImportKind.Default); } } @@ -391,24 +387,43 @@ namespace ts.codefix { if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { addSymbol(moduleSymbol, exportSymbolWithIdenticalName, ImportKind.Named); } - - function getEscapedNameForExportDefault(symbol: Symbol): __String | undefined { - return symbol.declarations && firstDefined(symbol.declarations, declaration => { - if (isExportAssignment(declaration)) { - if (isIdentifier(declaration.expression)) { - return declaration.expression.escapedText; - } - } - else if (isExportSpecifier(declaration)) { - Debug.assert(declaration.name.escapedText === InternalSymbolName.Default); - return declaration.propertyName && declaration.propertyName.escapedText; - } - }); - } }); return originalSymbolToExportInfos; } + function getDefaultExportInfo(defaultExport: Symbol, moduleSymbol: Symbol, program: Program): { readonly symbolForMeaning: Symbol, readonly name: string } | undefined { + const checker = program.getTypeChecker(); + + const localSymbol = getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) return { symbolForMeaning: localSymbol, name: localSymbol.name }; + + const name = getNameForExportDefault(defaultExport); + if (name !== undefined) return { symbolForMeaning: defaultExport, name }; + + if (defaultExport.flags & SymbolFlags.Alias) { + const aliased = checker.getAliasedSymbol(defaultExport); + return getDefaultExportInfo(aliased, Debug.assertDefined(aliased.parent), program); + } + else { + const moduleName = moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target!); + return moduleName === undefined ? undefined : { symbolForMeaning: defaultExport, name: moduleName }; + } + } + + function getNameForExportDefault(symbol: Symbol): string | undefined { + return symbol.declarations && firstDefined(symbol.declarations, declaration => { + if (isExportAssignment(declaration)) { + if (isIdentifier(declaration.expression)) { + return declaration.expression.text; + } + } + else if (isExportSpecifier(declaration)) { + Debug.assert(declaration.name.text === InternalSymbolName.Default); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } + function codeActionForFix(context: textChanges.TextChangesContext, sourceFile: SourceFile, symbolName: string, fix: ImportFix, quotePreference: QuotePreference): CodeFixAction { let diag!: DiagnosticAndArguments; const changes = textChanges.ChangeTracker.with(context, tracker => { diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index e0ce611af2e..6bc55f54ff7 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -498,7 +498,7 @@ namespace ts.FindAllReferences.Core { return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); } - /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ + /** @param allSearchSymbols set of additional symbols for use by `includes`. */ createSearch(location: Node | undefined, symbol: Symbol, comingFrom: ImportExport | undefined, searchOptions: { text?: string, allSearchSymbols?: Symbol[] } = {}): Search { // Note: if this is an external module symbol, the name doesn't include quotes. // Note: getLocalSymbolForExportDefault handles `export default class C {}`, but not `export default C` or `export { C as default }`. diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 1b6f21ac640..d6af6add125 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -1,48 +1,83 @@ /* @internal */ namespace ts.JsDoc { const jsDocTagNames = [ + "abstract", + "access", + "alias", + "argument", + "async", "augments", "author", - "argument", "borrows", "callback", "class", + "classDesc", "constant", "constructor", "constructs", + "copyright", "default", "deprecated", "description", + "emits", + "enum", "event", "example", + "exports", "extends", + "external", "field", + "file", "fileOverview", + "fires", "function", + "generator", + "global", + "hideConstructor", + "host", "ignore", + "implements", "inheritDoc", "inner", + "instance", + "interface", + "kind", "lends", - "link", + "license", + "listens", + "member", "memberOf", "method", + "mixes", + "module", "name", "namespace", + "override", + "package", "param", "private", - "prop", "property", + "protected", "public", + "readonly", "requires", "returns", "see", "since", "static", + "summary", "template", + "this", "throws", + "todo", + "tutorial", "type", "typedef", - "version" + "var", + "variation", + "version", + "virtual", + "yields" ]; let jsDocTagNameCompletionEntries: CompletionEntry[]; let jsDocTagCompletionEntries: CompletionEntry[]; diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 38ac57255f4..00a9a9d4f3b 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -17,7 +17,7 @@ namespace ts.NavigateTo { for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - if (excludeDtsFiles && fileExtensionIs(sourceFile.fileName, Extension.Dts)) { + if (excludeDtsFiles && sourceFile.isDeclarationFile) { continue; } diff --git a/src/services/services.ts b/src/services/services.ts index d9a93d5631d..d294f53830c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1129,8 +1129,6 @@ namespace ts { localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } - let sourcemappedFileCache: SourceFileLikeCache; - function log(message: string) { if (host.log) { host.log(message); @@ -1140,6 +1138,8 @@ namespace ts { const useCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames(host); const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); + const sourceMapper = getSourceMapper(getCanonicalFileName, currentDirectory, log, host, () => program); + function getValidSourceFile(fileName: string): SourceFile { const sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -1251,7 +1251,7 @@ namespace ts { // We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above, // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during // the course of whatever called `synchronizeHostData` - sourcemappedFileCache = createSourceFileLikeCache(host); + sourceMapper.clearCache(); // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. @@ -1502,183 +1502,27 @@ namespace ts { return checker.getSymbolAtLocation(node); } - function toLineColumnOffset(fileName: string, position: number) { - const path = toPath(fileName, currentDirectory, getCanonicalFileName); - const 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]) - const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; - const whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; - const base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; - function scanForSourcemapURL(fileName: string) { - const mappedFile = sourcemappedFileCache.get(toPath(fileName, currentDirectory, getCanonicalFileName)); - if (!mappedFile) { - return; - } - const starts = getLineStarts(mappedFile); - for (let index = starts.length - 1; index >= 0; index--) { - const lineText = mappedFile.text.substring(starts[index], starts[index + 1]); - const comment = sourceMapCommentRegExp.exec(lineText); - if (comment) { - return comment[1]; - } - // If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file - else if (!lineText.match(whitespaceOrMapCommentRegExp)) { - break; - } - } - } - - function convertDocumentToSourceMapper(file: { sourceMapper?: sourcemaps.SourceMapper }, contents: string, mapFileName: string) { - let maps: sourcemaps.SourceMapData | undefined; - try { - maps = JSON.parse(contents); - } - catch { - // swallow error - } - if (!maps || !maps.sources || !maps.file || !maps.mappings) { - // obviously invalid map - return file.sourceMapper = sourcemaps.identitySourceMapper; - } - return file.sourceMapper = sourcemaps.decode({ - readFile: s => host.readFile!(s), // TODO: GH#18217 - fileExists: s => host.fileExists!(s), // TODO: GH#18217 - getCanonicalFileName, - log, - }, mapFileName, maps, program, sourcemappedFileCache); - } - - function getSourceMapper(fileName: string, file: { sourceMapper?: sourcemaps.SourceMapper }) { - if (!host.readFile || !host.fileExists) { - return file.sourceMapper = sourcemaps.identitySourceMapper; - } - if (file.sourceMapper) { - return file.sourceMapper; - } - let mapFileName = scanForSourcemapURL(fileName); - if (mapFileName) { - const match = base64UrlRegExp.exec(mapFileName); - if (match) { - if (match[1]) { - const base64Object = match[1]; - return convertDocumentToSourceMapper(file, base64decode(sys, base64Object), fileName); - } - // Not a data URL we can parse, skip it - mapFileName = undefined; - } - } - const possibleMapLocations: string[] = []; - if (mapFileName) { - possibleMapLocations.push(mapFileName); - } - possibleMapLocations.push(fileName + ".map"); - for (const location of possibleMapLocations) { - const mapPath = toPath(location, getDirectoryPath(fileName), getCanonicalFileName); - if (host.fileExists(mapPath)) { - return convertDocumentToSourceMapper(file, host.readFile(mapPath)!, mapPath); // TODO: GH#18217 - } - } - return file.sourceMapper = sourcemaps.identitySourceMapper; - } - - function makeGetTargetOfMappedPosition( - extract: (original: TIn) => sourcemaps.SourceMappableLocation, - create: (result: sourcemaps.SourceMappableLocation, unmapped: TIn, original: TIn) => TIn - ) { - return getTargetOfMappedPosition; - function getTargetOfMappedPosition(input: TIn, original = input): TIn { - const info = extract(input); - if (endsWith(info.fileName, Extension.Dts)) { - let file: SourceFileLike | undefined = program.getSourceFile(info.fileName); - if (!file) { - const path = toPath(info.fileName, currentDirectory, getCanonicalFileName); - file = sourcemappedFileCache.get(path); - } - if (!file) { - return input; - } - const mapper = getSourceMapper(info.fileName, file); - const newLoc = mapper.getOriginalPosition(info); - if (newLoc === info) return input; - return getTargetOfMappedPosition(create(newLoc, input, original), original); - } - return input; - } - } - - const getTargetOfMappedDeclarationInfo = makeGetTargetOfMappedPosition( - (info: DefinitionInfo) => ({ fileName: info.fileName, position: info.textSpan.start }), - (newLoc, info, original) => ({ - containerKind: info.containerKind, - containerName: info.containerName, - fileName: newLoc.fileName, - kind: info.kind, - name: info.name, - textSpan: { - start: newLoc.position, - length: info.textSpan.length - }, - originalFileName: original.fileName, - originalTextSpan: original.textSpan - }) - ); - - function getTargetOfMappedDeclarationFiles(infos: ReadonlyArray | undefined): DefinitionInfo[] | undefined { - return map(infos, d => getTargetOfMappedDeclarationInfo(d)); - } - /// Goto definition function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined { synchronizeHostData(); - return getTargetOfMappedDeclarationFiles(GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position)); + return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); } function getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined { synchronizeHostData(); - const result = GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position); - if (!result) return result; - const mappedDefs = getTargetOfMappedDeclarationFiles(result.definitions); - if (mappedDefs === result.definitions) { - return result; - } - return { - definitions: mappedDefs, - textSpan: result.textSpan - }; + return GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position); } function getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined { synchronizeHostData(); - return getTargetOfMappedDeclarationFiles(GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position)); + return GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); } /// Goto implementation - const getTargetOfMappedImplementationLocation = makeGetTargetOfMappedPosition( - (info: ImplementationLocation) => ({ fileName: info.fileName, position: info.textSpan.start }), - (newLoc, info) => ({ - fileName: newLoc.fileName, - kind: info.kind, - displayParts: info.displayParts, - textSpan: { - start: newLoc.position, - length: info.textSpan.length - }, - originalFileName: info.fileName, - originalTextSpan: info.textSpan - }) - ); - - function getTargetOfMappedImplementationLocations(infos: ReadonlyArray | undefined): ImplementationLocation[] | undefined { - return map(infos, d => getTargetOfMappedImplementationLocation(d)); - } - function getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] | undefined { synchronizeHostData(); - return getTargetOfMappedImplementationLocations(FindAllReferences.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position)); + return FindAllReferences.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } /// References and Occurrences @@ -1735,10 +1579,8 @@ namespace ts { return FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } - /// NavigateTo function getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles = false): NavigateToItem[] { synchronizeHostData(); - const sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } @@ -2289,7 +2131,8 @@ namespace ts { getProgram, getApplicableRefactors, getEditsForRefactor, - toLineColumnOffset + toLineColumnOffset: sourceMapper.toLineColumnOffset, + getSourceMapper: () => sourceMapper, }; } diff --git a/src/services/shims.ts b/src/services/shims.ts index 0776f55c905..a4674143033 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -102,7 +102,7 @@ namespace ts { readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; /** - * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules + * Read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules */ readFile(fileName: string): string | undefined; realpath?(path: string): string; diff --git a/src/services/sourcemaps.ts b/src/services/sourcemaps.ts new file mode 100644 index 00000000000..f617d879893 --- /dev/null +++ b/src/services/sourcemaps.ts @@ -0,0 +1,115 @@ +/* @internal */ +namespace ts { + // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) + const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + const whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; + const base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; + + export interface SourceMapper { + toLineColumnOffset(fileName: string, position: number): LineAndCharacter; + tryGetOriginalLocation(info: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined; + clearCache(): void; + } + + export function getSourceMapper( + getCanonicalFileName: GetCanonicalFileName, + currentDirectory: string, + log: (message: string) => void, + host: LanguageServiceHost, + getProgram: () => Program, + ): SourceMapper { + let sourcemappedFileCache: SourceFileLikeCache; + return { tryGetOriginalLocation, toLineColumnOffset, clearCache }; + + function scanForSourcemapURL(fileName: string) { + const mappedFile = sourcemappedFileCache.get(toPath(fileName, currentDirectory, getCanonicalFileName)); + if (!mappedFile) { + return; + } + const starts = getLineStarts(mappedFile); + for (let index = starts.length - 1; index >= 0; index--) { + const lineText = mappedFile.text.substring(starts[index], starts[index + 1]); + const comment = sourceMapCommentRegExp.exec(lineText); + if (comment) { + return comment[1]; + } + // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!lineText.match(whitespaceOrMapCommentRegExp)) { + break; + } + } + } + + function convertDocumentToSourceMapper(file: { sourceMapper?: sourcemaps.SourceMapper }, contents: string, mapFileName: string) { + let maps: sourcemaps.SourceMapData | undefined; + try { + maps = JSON.parse(contents); + } + catch { + // swallow error + } + if (!maps || !maps.sources || !maps.file || !maps.mappings) { + // obviously invalid map + return file.sourceMapper = sourcemaps.identitySourceMapper; + } + return file.sourceMapper = sourcemaps.decode({ + readFile: s => host.readFile!(s), // TODO: GH#18217 + fileExists: s => host.fileExists!(s), // TODO: GH#18217 + getCanonicalFileName, + log, + }, mapFileName, maps, getProgram(), sourcemappedFileCache); + } + + function getSourceMapper(fileName: string, file: SourceFileLike): sourcemaps.SourceMapper { + if (!host.readFile || !host.fileExists) { + return file.sourceMapper = sourcemaps.identitySourceMapper; + } + if (file.sourceMapper) { + return file.sourceMapper; + } + let mapFileName = scanForSourcemapURL(fileName); + if (mapFileName) { + const match = base64UrlRegExp.exec(mapFileName); + if (match) { + if (match[1]) { + const base64Object = match[1]; + return convertDocumentToSourceMapper(file, base64decode(sys, base64Object), fileName); + } + // Not a data URL we can parse, skip it + mapFileName = undefined; + } + } + const possibleMapLocations: string[] = []; + if (mapFileName) { + possibleMapLocations.push(mapFileName); + } + possibleMapLocations.push(fileName + ".map"); + for (const location of possibleMapLocations) { + const mapPath = toPath(location, getDirectoryPath(fileName), getCanonicalFileName); + if (host.fileExists(mapPath)) { + return convertDocumentToSourceMapper(file, host.readFile(mapPath)!, mapPath); // TODO: GH#18217 + } + } + return file.sourceMapper = sourcemaps.identitySourceMapper; + } + + function tryGetOriginalLocation(info: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined { + if (!isDeclarationFileName(info.fileName)) return undefined; + + const file = getProgram().getSourceFile(info.fileName) || sourcemappedFileCache.get(toPath(info.fileName, currentDirectory, getCanonicalFileName)); + if (!file) return undefined; + const newLoc = getSourceMapper(info.fileName, file).getOriginalPosition(info); + return newLoc === info ? undefined : tryGetOriginalLocation(newLoc) || newLoc; + } + + function toLineColumnOffset(fileName: string, position: number): LineAndCharacter { + const path = toPath(fileName, currentDirectory, getCanonicalFileName); + const file = getProgram().getSourceFile(path) || sourcemappedFileCache.get(path)!; // TODO: GH#18217 + return file.getLineAndCharacterOfPosition(position); + } + + function clearCache(): void { + sourcemappedFileCache = createSourceFileLikeCache(host); + } + } +} diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 6e1495d78a2..355a4d302c0 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -29,6 +29,7 @@ "preProcess.ts", "rename.ts", "signatureHelp.ts", + "sourcemaps.ts", "suggestionDiagnostics.ts", "symbolDisplay.ts", "transpile.ts", diff --git a/src/services/types.ts b/src/services/types.ts index 45eb637f0dc..51c98724c09 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -334,6 +334,8 @@ namespace ts { getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; + /** @internal */ + getSourceMapper(): SourceMapper; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 7a4712e15cd..b87ec2610d8 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1417,6 +1417,13 @@ namespace ts { changes.insertNodeAtTopOfFile(sourceFile, importDecl, /*blankLineBetween*/ true); } } + + export function textSpansEqual(a: TextSpan | undefined, b: TextSpan | undefined): boolean { + return !!a && !!b && a.start === b.start && a.length === b.length; + } + export function documentSpansEqual(a: DocumentSpan, b: DocumentSpan): boolean { + return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan); + } } // Display-part writer helpers diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 988e181852a..c10be2a9ff8 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -20,6 +20,7 @@ namespace Harness.Parallel.Host { // tslint:disable-next-line:variable-name const FailedTestReporter = require(path.resolve(__dirname, "../../scripts/failed-tests")) as typeof import("../../../scripts/failed-tests"); + const perfdataFileNameFragment = ".parallelperf"; const perfData = readSavedPerfData(configOption); const newTasks: Task[] = []; let tasks: Task[] = []; @@ -175,8 +176,6 @@ namespace Harness.Parallel.Host { } } - const perfdataFileNameFragment = ".parallelperf"; - function perfdataFileName(target?: string) { return `${perfdataFileNameFragment}${target ? `.${target}` : ""}.json`; } diff --git a/src/testRunner/unittests/convertToBase64.ts b/src/testRunner/unittests/convertToBase64.ts index e41f73034c4..ecf55d9855b 100644 --- a/src/testRunner/unittests/convertToBase64.ts +++ b/src/testRunner/unittests/convertToBase64.ts @@ -2,7 +2,7 @@ namespace ts { describe("convertToBase64", () => { function runTest(input: string): void { const actual = convertToBase64(input); - const expected = new Buffer(input).toString("base64"); + const expected = (Buffer.from ? Buffer.from(input) : new Buffer(input)).toString("base64"); assert.equal(actual, expected, "Encoded string using convertToBase64 does not match buffer.toString('base64')"); } diff --git a/src/testRunner/unittests/factory.ts b/src/testRunner/unittests/factory.ts index c2b4df8901b..11ff65a8558 100644 --- a/src/testRunner/unittests/factory.ts +++ b/src/testRunner/unittests/factory.ts @@ -45,6 +45,8 @@ namespace ts { checkBody(createPropertyAccess(createObjectLiteral(), "prop")); checkBody(createAsExpression(createPropertyAccess(createObjectLiteral(), "prop"), createTypeReferenceNode("T", /*typeArguments*/ undefined))); checkBody(createNonNullExpression(createPropertyAccess(createObjectLiteral(), "prop"))); + checkBody(createCommaList([createLiteral("a"), createLiteral("b")])); + checkBody(createBinary(createLiteral("a"), SyntaxKind.CommaToken, createLiteral("b"))); }); }); }); diff --git a/src/testRunner/unittests/tsserverProjectSystem.ts b/src/testRunner/unittests/tsserverProjectSystem.ts index 95d1686a149..e38d80667bc 100644 --- a/src/testRunner/unittests/tsserverProjectSystem.ts +++ b/src/testRunner/unittests/tsserverProjectSystem.ts @@ -415,7 +415,7 @@ namespace ts.projectSystem { checkArray("Open files", arrayFrom(projectService.openFiles.keys(), path => projectService.getScriptInfoForPath(path as Path)!.fileName), expectedFiles.map(file => file.path)); } - function protocolLocationFromSubstring(str: string, substring: string) { + function protocolLocationFromSubstring(str: string, substring: string): protocol.Location { const start = str.indexOf(substring); Debug.assert(start !== -1); return protocolToLocation(str)(start); @@ -427,21 +427,36 @@ namespace ts.projectSystem { return { line: x.line + 1, offset: x.character + 1 }; }; } - function protocolTextSpanFromSubstring(str: string, substring: string): protocol.TextSpan { - const span = textSpanFromSubstring(str, substring); + function protocolTextSpanFromSubstring(str: string, substring: string, options?: SpanFromSubstringOptions): protocol.TextSpan { + const span = textSpanFromSubstring(str, substring, options); const toLocation = protocolToLocation(str); - return { start: toLocation(span.start), end: toLocation(span.start + span.length) }; + return { start: toLocation(span.start), end: toLocation(textSpanEnd(span)) }; } - function textSpanFromSubstring(str: string, substring: string): TextSpan { - const start = str.indexOf(substring); + function textSpanFromSubstring(str: string, substring: string, options?: SpanFromSubstringOptions): TextSpan { + const start = nthIndexOf(str, substring, options ? options.index : 0); Debug.assert(start !== -1); return createTextSpan(start, substring.length); } function protocolFileLocationFromSubstring(file: File, substring: string): protocol.FileLocationRequestArgs { return { file: file.path, ...protocolLocationFromSubstring(file.content, substring) }; } - function protocolFileSpanFromSubstring(file: File, substring: string): protocol.FileSpan { - return { file: file.path, ...protocolTextSpanFromSubstring(file.content, substring) }; + function protocolFileSpanFromSubstring(file: File, substring: string, options?: SpanFromSubstringOptions) { + return { file: file.path, ...protocolTextSpanFromSubstring(file.content, substring, options) }; + } + function documentSpanFromSubstring(file: File, substring: string, options?: SpanFromSubstringOptions): DocumentSpan { + return { fileName: file.path, textSpan: textSpanFromSubstring(file.content, substring, options) }; + } + interface SpanFromSubstringOptions { + readonly index: number; + } + + function nthIndexOf(str: string, substr: string, n: number): number { + let index = -1; + for (; n >= 0; n--) { + index = str.indexOf(substr, index + 1); + if (index === -1) return -1; + } + return index; } /** @@ -496,10 +511,14 @@ namespace ts.projectSystem { }; } - export function openFilesForSession(files: ReadonlyArray, session: server.Session): void { + export function executeSessionRequest(session: server.Session, command: TRequest["command"], args: TRequest["arguments"]): TResponse["body"] { + return session.executeCommand(makeSessionRequest(command, args)).response as TResponse["body"]; + } + + export function openFilesForSession(files: ReadonlyArray, session: server.Session): void { for (const file of files) { - const request = makeSessionRequest(CommandNames.Open, { file: file.path }); - session.executeCommand(request); + session.executeCommand(makeSessionRequest(CommandNames.Open, + "projectRootPath" in file ? { file: typeof file.file === "string" ? file.file : file.file.path, projectRootPath: file.projectRootPath } : { file: file.path })); } } @@ -3385,7 +3404,7 @@ namespace ts.projectSystem { host.reloadFS(files.map(f => f === fileSubA ? fileA : f)); host.checkTimeoutQueueLength(2); - closeFile(fileSubA); + closeFilesForSession([fileSubA], session); // This should cancel existing updates and schedule new ones host.checkTimeoutQueueLength(2); checkNumberOfProjects(services, { configuredProjects: 1 }); @@ -3405,7 +3424,7 @@ namespace ts.projectSystem { // file is deleted but watches are not yet invoked const originalFileExists = host.fileExists; host.fileExists = s => s === fileA.path ? false : originalFileExists.call(host, s); - closeFile(fileA); + closeFilesForSession([fileA], session); host.checkTimeoutQueueLength(2); // Update configured project and projects for open file checkProjectActualFiles(services.configuredProjects.get(config.path)!, filesWithFileA.map(f => f.path)); @@ -3453,23 +3472,7 @@ namespace ts.projectSystem { assert.isFalse(hasErrorMsg()); function openFile(file: File) { - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: file.path, - fileContent: file.content, - projectRootPath - } - }); - } - - function closeFile(file: File) { - session.executeCommandSeq({ - command: protocol.CommandTypes.Close, - arguments: { - file: file.path - } - }); + openFilesForSession([{ file, projectRootPath }], session); } }); }); @@ -3686,40 +3689,17 @@ namespace ts.projectSystem { const files = [libFile, app, serverUtilities, backendTest]; const host = createServerHost(files); const session = createSession(host, { useInferredProjectPerProjectRoot: true, canUseEvents: true }); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: app.path, - projectRootPath: projectRoot - } - }); + openFilesForSession([{ file: app, projectRootPath: projectRoot }], session); const service = session.getProjectService(); checkNumberOfProjects(service, { inferredProjects: 1 }); const project = service.inferredProjects[0]; checkProjectActualFiles(project, [libFile.path, app.path]); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: backendTest.path, - projectRootPath: projectRoot - } - }); + openFilesForSession([{ file: backendTest, projectRootPath: projectRoot }], session); checkNumberOfProjects(service, { inferredProjects: 1 }); checkProjectActualFiles(project, files.map(f => f.path)); checkErrors([backendTest.path, app.path]); - session.executeCommandSeq({ - command: protocol.CommandTypes.Close, - arguments: { - file: backendTest.path - } - }); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: serverUtilities.path, - projectRootPath: projectRoot - } - }); + closeFilesForSession([backendTest], session); + openFilesForSession([{ file: serverUtilities.path, projectRootPath: projectRoot }], session); checkErrors([serverUtilities.path, app.path]); function checkErrors(openFiles: [string, string]) { @@ -7886,72 +7866,42 @@ namespace ts.projectSystem { const host = createServerHost(files); const session = createSession(host); const projectService = session.getProjectService(); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: aFile.path, - projectRootPath: folderA - } - }); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: bFile.path, - projectRootPath: folderB - } - }); - - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: aFc, - projectRootPath: folderA - } - }); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: bFc, - projectRootPath: folderB - } - }); + openFilesForSession( + [ + { file: aFile, projectRootPath: folderA }, + { file: bFile, projectRootPath: folderB }, + { file: aFc, projectRootPath: folderA }, + { file: bFc, projectRootPath: folderB }, + ], + session); checkNumberOfProjects(projectService, { configuredProjects: 2 }); assert.isDefined(projectService.configuredProjects.get(aTsconfig.path)); assert.isDefined(projectService.configuredProjects.get(bTsconfig.path)); - verifyRenameResponse(session.executeCommandSeq({ - command: protocol.CommandTypes.Rename, - arguments: { - file: aFc, - line: 1, - offset: 14, - findInStrings: false, - findInComments: false - } - }).response as protocol.RenameResponseBody); + const response = executeSessionRequest(session, protocol.CommandTypes.Rename, { file: aFc, ...protocolLocationFromSubstring(cFile.content, "C") }); - function verifyRenameResponse({ info, locs }: protocol.RenameResponseBody) { - assert.isTrue(info.canRename); - assert.equal(locs.length, 4); - verifyLocations(0, aFile.path, aFc); - verifyLocations(2, bFile.path, bFc); - - function verifyLocations(locStartIndex: number, firstFile: string, secondFile: string) { - assert.deepEqual(locs[locStartIndex], { - file: firstFile, - locs: [ - { start: { line: 1, offset: 39 }, end: { line: 1, offset: 40 } }, - { start: { line: 1, offset: 9 }, end: { line: 1, offset: 10 } } - ] - }); - assert.deepEqual(locs[locStartIndex + 1], { - file: secondFile, - locs: [ - { start: { line: 1, offset: 14 }, end: { line: 1, offset: 15 } } - ] - }); - } - } + assert.equal(aFile.content, bFile.content); + const abLocs: protocol.TextSpan[] = [ + protocolTextSpanFromSubstring(aFile.content, "C"), + protocolTextSpanFromSubstring(aFile.content, "C", { index: 1 }), + ]; + const cLocs: protocol.TextSpan[] = [protocolTextSpanFromSubstring(cFile.content, "C")]; + assert.deepEqual(response, { + info: { + canRename: true, + displayName: "C", + fullDisplayName: '"/users/username/projects/a/c/fc".C', + kind: ScriptElementKind.constElement, + kindModifiers: ScriptElementKindModifier.exportedModifier, + localizedErrorMessage: undefined, + }, + locs: [ + { file: aFc, locs: cLocs }, + { file: aFile.path, locs: abLocs }, + { file: bFc, locs: cLocs }, + { file: bFile.path, locs: abLocs }, + ], + }); }); describe("module resolution when symlinked folder contents change and resolve modules", () => { @@ -8948,93 +8898,323 @@ export function Test2() { function makeSampleProjects() { const aTs: File = { path: "/a/a.ts", - content: "export function fnA() {}", + content: "export function fnA() {}\nexport interface IfaceA {}\nexport const instanceA: IfaceA = {};", }; - const aTsconfig: File = { - path: "/a/tsconfig.json", - content: `{ - "compilerOptions": { - "outDir": "bin", - "declaration": true, - "declarationMap": true, - "composite": true, - } - }`, + const compilerOptions: CompilerOptions = { + outDir: "bin", + declaration: true, + declarationMap: true, + composite: true, + }; + const configContent = JSON.stringify({ compilerOptions }); + const aTsconfig: File = { path: "/a/tsconfig.json", content: configContent }; + + const aDtsMapContent: SourceMapSection = { + version: 3, + file: "a.d.ts", + sourceRoot: "", + sources: ["../a.ts"], + names: [], + mappings: "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" + }; + const aDtsMap: File = { + path: "/a/bin/a.d.ts.map", + content: JSON.stringify(aDtsMapContent), + }; + const aDts: File = { + path: "/a/bin/a.d.ts", + // Need to mangle the sourceMappingURL part or it breaks the build + content: `export declare function fnA(): void;\nexport interface IfaceA {\n}\nexport declare const instanceA: IfaceA;\n//# source${""}MappingURL=a.d.ts.map`, }; const bTs: File = { path: "/b/b.ts", - content: 'import { fnA } from "../a/a";\nexport function fnB() { fnA(); }', + content: "export function fnB() {}", }; - const bTsconfig: File = { - path: "/b/tsconfig.json", - content: `{ - "compilerOptions": { - "outDir": "bin", - }, - "references": [ - { "path": "../a" } - ] - }`, + const bTsconfig: File = { path: "/b/tsconfig.json", content: configContent }; + + const bDtsMapContent: SourceMapSection = { + version: 3, + file: "b.d.ts", + sourceRoot: "", + sources: ["../b.ts"], + names: [], + mappings: "AAAA,wBAAgB,GAAG,SAAK", + }; + const bDtsMap: File = { + path: "/b/bin/b.d.ts.map", + content: JSON.stringify(bDtsMapContent), + }; + const bDts: File = { + // Need to mangle the sourceMappingURL part or it breaks the build + path: "/b/bin/b.d.ts", + content: `export declare function fnB(): void;\n//# source${""}MappingURL=b.d.ts.map`, }; - const host = createServerHost([aTs, aTsconfig, bTs, bTsconfig]); + const userTs: File = { + path: "/user/user.ts", + content: 'import { fnA, instanceA } from "../a/bin/a";\nimport { fnB } from "../b/bin/b";\nexport function fnUser() { fnA(); fnB(); instanceA; }', + }; + + const host = createServerHost([aTs, aTsconfig, aDtsMap, aDts, bTsconfig, bTs, bDtsMap, bDts, userTs]); const session = createSession(host); - writeDeclarationFiles(aTs, host, session, [ - { name: "/a/bin/a.d.ts.map", text: '{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../a.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAK"}' }, - // Need to mangle the sourceMappingURL part or it breaks the build - { name: "/a/bin/a.d.ts", text: `export declare function fnA(): void;\n//# source${""}MappingURL=a.d.ts.map` }, - ]); + checkDeclarationFiles(aTs, session, [aDtsMap, aDts]); + checkDeclarationFiles(bTs, session, [bDtsMap, bDts]); - return { session, aTs, bTs }; + // Testing what happens if we delete the original sources. + host.removeFile(bTs.path); + + openFilesForSession([userTs], session); + + return { session, aTs, bDts, userTs }; } describe("tsserverProjectSystem project references", () => { it("goToDefinition", () => { - const { session, aTs, bTs } = makeSampleProjects(); + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.Definition, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "fnA")]); + }); - openFilesForSession([bTs], session); + it("getDefinitionAndBoundSpan", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.DefinitionAndBoundSpan, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, { + textSpan: protocolTextSpanFromSubstring(userTs.content, "fnA", { index: 1 }), + definitions: [protocolFileSpanFromSubstring(aTs, "fnA")], + }); + }); - const definitionRequest = makeSessionRequest(CommandNames.Definition, protocolFileLocationFromSubstring(bTs, "fnA()")); - const definitionResponse = session.executeCommand(definitionRequest).response as protocol.DefinitionResponse["body"]; + it("goToType", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.TypeDefinition, protocolFileLocationFromSubstring(userTs, "instanceA")); + assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "IfaceA")]); + }); - assert.deepEqual(definitionResponse, [protocolFileSpanFromSubstring(aTs, "fnA")]); + it("goToImplementation", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.Implementation, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "fnA")]); + }); + + it("goToDefinition -- target does not exist", () => { + const { session, bDts, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, CommandNames.Definition, protocolFileLocationFromSubstring(userTs, "fnB()")); + // bTs does not exist, so stick with bDts + assert.deepEqual(response, [protocolFileSpanFromSubstring(bDts, "fnB")]); }); it("navigateTo", () => { - const { session, bTs } = makeSampleProjects(); - - openFilesForSession([bTs], session); - - const navtoRequest = makeSessionRequest(CommandNames.Navto, { file: bTs.path, searchValue: "fn" }); - const navtoResponse = session.executeCommand(navtoRequest).response as protocol.NavtoResponse["body"]; - - assert.deepEqual | undefined>(navtoResponse, [ - // TODO: First result should be from a.ts, not a.d.ts + const { session, aTs, bDts, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, CommandNames.Navto, { file: userTs.path, searchValue: "fn" }); + assert.deepEqual | undefined>(response, [ { - file: "/a/bin/a.d.ts", - start: { line: 1, offset: 1 }, - end: { line: 1, offset: 37 }, - name: "fnA", + ...protocolFileSpanFromSubstring(bDts, "export declare function fnB(): void;"), + name: "fnB", matchKind: "prefix", isCaseSensitive: true, kind: ScriptElementKind.functionElement, kindModifiers: "export,declare", }, { - ...protocolFileSpanFromSubstring(bTs, "export function fnB() { fnA(); }"), - name: "fnB", + ...protocolFileSpanFromSubstring(userTs, "export function fnUser() { fnA(); fnB(); instanceA; }"), + name: "fnUser", matchKind: "prefix", isCaseSensitive: true, kind: ScriptElementKind.functionElement, kindModifiers: "export", + }, + { + ...protocolFileSpanFromSubstring(aTs, "export function fnA() {}"), + name: "fnA", + matchKind: "prefix", + isCaseSensitive: true, + kind: ScriptElementKind.functionElement, + kindModifiers: "export", + }, + ]); + }); + + it("findAllReferences", () => { + const { session, aTs, userTs } = makeSampleProjects(); + + const response = executeSessionRequest(session, protocol.CommandTypes.References, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, { + refs: [ + makeReferenceItem(userTs, /*isDefinition*/ true, "fnA"), + makeReferenceItem(userTs, /*isDefinition*/ false, "fnA", { index: 1 }), + makeReferenceItem(aTs, /*isDefinition*/ true, "fnA"), + ], + symbolName: "fnA", + symbolStartOffset: protocolLocationFromSubstring(userTs.content, "fnA()").offset, + symbolDisplayString: "(alias) fnA(): void\nimport fnA", + }); + }); + + it("findAllReferencesFull", () => { + const { session, aTs, userTs } = makeSampleProjects(); + + interface ReferencesFullRequest extends protocol.FileLocationRequest { command: protocol.CommandTypes.ReferencesFull; } + interface ReferencesFullResponse extends protocol.Response { body: ReadonlyArray; } + const responseFull = executeSessionRequest(session, protocol.CommandTypes.ReferencesFull, protocolFileLocationFromSubstring(userTs, "fnA()")); + + function fnAVoid(kind: SymbolDisplayPartKind): SymbolDisplayPart[] { + return [ + keywordPart(SyntaxKind.FunctionKeyword), + spacePart(), + displayPart("fnA", kind), + punctuationPart(SyntaxKind.OpenParenToken), + punctuationPart(SyntaxKind.CloseParenToken), + punctuationPart(SyntaxKind.ColonToken), + spacePart(), + keywordPart(SyntaxKind.VoidKeyword), + ]; + } + assert.deepEqual>(responseFull, [ + { + definition: { + ...documentSpanFromSubstring(userTs, "fnA"), + kind: ScriptElementKind.alias, + name: "(alias) function fnA(): void\nimport fnA", + containerKind: ScriptElementKind.unknown, + containerName: "", + displayParts: [ + punctuationPart(SyntaxKind.OpenParenToken), + textPart("alias"), + punctuationPart(SyntaxKind.CloseParenToken), + spacePart(), + ...fnAVoid(SymbolDisplayPartKind.aliasName), + lineBreakPart(), + keywordPart(SyntaxKind.ImportKeyword), + spacePart(), + displayPart("fnA", SymbolDisplayPartKind.aliasName), + ], + }, + references: [ + makeReferenceEntry(userTs, /*isDefinition*/ true, "fnA"), + makeReferenceEntry(userTs, /*isDefinition*/ false, "fnA", { index: 1 }), + ], + }, + { + definition: { + ...documentSpanFromSubstring(aTs, "fnA"), + kind: ScriptElementKind.functionElement, + name: "function fnA(): void", + containerKind: ScriptElementKind.unknown, + containerName: "", + displayParts: fnAVoid(SymbolDisplayPartKind.functionName), + }, + references: [ + makeReferenceEntry(aTs, /*isDefinition*/ true, "fnA"), + ], } ]); }); + + it("findAllReferences -- target does not exist", () => { + const { session, bDts, userTs } = makeSampleProjects(); + + const response = executeSessionRequest(session, protocol.CommandTypes.References, protocolFileLocationFromSubstring(userTs, "fnB()")); + assert.deepEqual(response, { + refs: [ + makeReferenceItem(userTs, /*isDefinition*/ true, "fnB"), + makeReferenceItem(userTs, /*isDefinition*/ false, "fnB", { index: 1 }), + makeReferenceItem(bDts, /*isDefinition*/ true, "fnB"), + ], + symbolName: "fnB", + symbolStartOffset: protocolLocationFromSubstring(userTs.content, "fnB()").offset, + symbolDisplayString: "(alias) fnB(): void\nimport fnB", + }); + }); + + it("renameLocations", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, { + info: { + canRename: true, + displayName: "fnA", + fullDisplayName: "fnA", + kind: ScriptElementKind.alias, + kindModifiers: ScriptElementKindModifier.none, + localizedErrorMessage: undefined, + }, + locs: [ + { + file: userTs.path, + locs: [ + protocolTextSpanFromSubstring(userTs.content, "fnA"), + protocolTextSpanFromSubstring(userTs.content, "fnA", { index: 1 }), + ], + }, + { + file: aTs.path, + locs: [protocolTextSpanFromSubstring(aTs.content, "fnA")], + } + ], + }); + }); + + it("renameLocationsFull", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.RenameLocationsFull, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual>(response, [ + documentSpanFromSubstring(userTs, "fnA"), + documentSpanFromSubstring(userTs, "fnA", { index: 1 }), + documentSpanFromSubstring(aTs, "fnA"), + ]); + }); + + it("renameLocations -- target does not exist", () => { + const { session, bDts, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(userTs, "fnB()")); + assert.deepEqual(response, { + info: { + canRename: true, + displayName: "fnB", + fullDisplayName: "fnB", + kind: ScriptElementKind.alias, + kindModifiers: ScriptElementKindModifier.none, + localizedErrorMessage: undefined, + }, + locs: [ + { + file: userTs.path, + locs: [ + protocolTextSpanFromSubstring(userTs.content, "fnB"), + protocolTextSpanFromSubstring(userTs.content, "fnB", { index: 1 }), + ], + }, + { + file: bDts.path, + locs: [protocolTextSpanFromSubstring(bDts.content, "fnB")], + } + ], + }); + + }); }); - function writeDeclarationFiles(file: File, host: TestServerHost, session: TestSession, expectedFiles: ReadonlyArray<{ readonly name: string, readonly text: string }>): void { + function makeReferenceItem(file: File, isDefinition: boolean, text: string, options?: SpanFromSubstringOptions): protocol.ReferencesResponseItem { + return { + ...protocolFileSpanFromSubstring(file, text, options), + isDefinition, + isWriteAccess: isDefinition, + lineText: text, + }; + } + + function makeReferenceEntry(file: File, isDefinition: boolean, text: string, options?: SpanFromSubstringOptions): ReferenceEntry { + return { + ...documentSpanFromSubstring(file, text, options), + isDefinition, + isWriteAccess: isDefinition, + isInString: undefined, + }; + } + + function checkDeclarationFiles(file: File, session: TestSession, expectedFiles: ReadonlyArray): void { openFilesForSession([file], session); const project = Debug.assertDefined(session.getProjectService().getDefaultProjectForFile(file.path as server.NormalizedPath, /*ensureProject*/ false)); const program = project.getCurrentProgram(); @@ -9042,12 +9222,6 @@ export function Test2() { closeFilesForSession([file], session); Debug.assert(!output.emitSkipped); - assert.deepEqual(output.outputFiles, expectedFiles.map(e => ({ ...e, writeByteOrderMark: false }))); - - for (const { name, text } of output.outputFiles) { - const directory: Folder = { path: getDirectoryPath(name) }; - host.ensureFileOrFolder(directory); - host.writeFile(name, text); - } + assert.deepEqual(output.outputFiles, expectedFiles.map((e): OutputFile => ({ name: e.path, text: e.content, writeByteOrderMark: false }))); } } diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index cbb91ae70a8..0a70fb3d83b 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -199,7 +199,7 @@ namespace ts.server { private write(s: string) { if (this.fd >= 0) { - const buf = new Buffer(s); + const buf = Buffer.from ? Buffer.from(s) : new Buffer(s); // tslint:disable-next-line no-null-keyword fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null!); // TODO: GH#18217 } @@ -869,7 +869,7 @@ namespace ts.server { } // Override sys.write because fs.writeSync is not reliable on Node 4 - sys.write = (s: string) => writeMessage(new Buffer(s, "utf8")); + sys.write = (s: string) => writeMessage(Buffer.from ? Buffer.from(s, "utf8") : new Buffer(s, "utf8")); sys.watchFile = (fileName, callback) => { const watchedFile = pollingWatchedFileSet.addFile(fileName, callback); return { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 99452b93d47..82b7e0c3ef8 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2544,7 +2544,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -3260,6 +3259,7 @@ declare namespace ts { aliasSymbol?: Symbol; aliasTypeArguments?: ReadonlyArray; wildcardInstantiation?: Type; + immediateBaseConstraint?: Type; } interface IntrinsicType extends Type { intrinsicName: string; @@ -5073,7 +5073,7 @@ declare namespace ts { An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: DiagnosticMessage; infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: DiagnosticMessage; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: DiagnosticMessage; - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: DiagnosticMessage; + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: DiagnosticMessage; Type_arguments_cannot_be_used_here: DiagnosticMessage; The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: DiagnosticMessage; Duplicate_identifier_0: DiagnosticMessage; @@ -7435,6 +7435,8 @@ declare namespace ts { jsDocTypeExpression: JSDocTypeExpression; diagnostics: Diagnostic[]; } | undefined; + /** @internal */ + function isDeclarationFileName(fileName: string): boolean; interface PragmaContext { languageVersion: ScriptTarget; pragmas?: PragmaMap; @@ -8371,6 +8373,9 @@ declare namespace ts { function parenthesizeElementTypeMembers(members: ReadonlyArray): NodeArray; function parenthesizeTypeParameters(typeParameters: ReadonlyArray | undefined): MutableNodeArray | undefined; function parenthesizeConciseBody(body: ConciseBody): ConciseBody; + function isCommaSequence(node: Expression): node is (BinaryExpression & { + operatorToken: Token; + }) | CommaListExpression; enum OuterExpressionKinds { Parentheses = 1, Assertions = 2, @@ -8601,17 +8606,6 @@ declare namespace ts.sourcemaps { readonly lastSpan: SourceMapSpan; } function decodeMappings(map: SourceMapData): MappingsDecoder; - function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { - log?(s: string): void; - }): T[]; - interface RawSourceMapPosition { - emittedLine: number; - emittedColumn: number; - sourceLine: number; - sourceColumn: number; - sourceIndex: number; - nameIndex?: number; - } } declare namespace ts { function getOriginalNodeId(node: Node): number; @@ -8815,6 +8809,16 @@ declare namespace ts { extendedDiagnostics?: boolean; } function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter, compilerOptions?: SourceMapOptions): SourceMapWriter; + interface SourceMapSection { + version: 3; + file: string; + sourceRoot?: string; + sources: string[]; + names?: string[]; + mappings: string; + sourcesContent?: (string | null)[]; + sections?: undefined; + } } declare namespace ts { interface CommentWriter { @@ -8978,10 +8982,14 @@ declare namespace ts { */ function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; function parseConfigHostFromCompilerHost(host: CompilerHost): ParseConfigFileHost; + interface ResolveProjectReferencePathHost { + fileExists(fileName: string): boolean; + } /** - * Returns the target config filename of a project reference + * Returns the target config filename of a project reference. + * Note: The file might not exist. */ - function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName; + function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. * The DiagnosticMessage's parameters are the imported module name, and the filename it resolved to. @@ -10037,6 +10045,8 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; + /** @internal */ + getSourceMapper(): SourceMapper; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand): Promise; @@ -10907,6 +10917,8 @@ declare namespace ts { function getParentNodeInSpan(node: Node | undefined, file: SourceFile, span: TextSpan): Node | undefined; function findModifier(node: Node, kind: Modifier["kind"]): Modifier | undefined; function insertImport(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importDecl: Statement): void; + function textSpansEqual(a: TextSpan | undefined, b: TextSpan | undefined): boolean; + function documentSpansEqual(a: DocumentSpan, b: DocumentSpan): boolean; } declare namespace ts { function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; @@ -11315,6 +11327,14 @@ declare namespace ts.SignatureHelp { } function getArgumentInfoForCompletions(node: Node, position: number, sourceFile: SourceFile): ArgumentInfoForCompletions | undefined; } +declare namespace ts { + interface SourceMapper { + toLineColumnOffset(fileName: string, position: number): LineAndCharacter; + tryGetOriginalLocation(info: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined; + clearCache(): void; + } + function getSourceMapper(getCanonicalFileName: GetCanonicalFileName, currentDirectory: string, log: (message: string) => void, host: LanguageServiceHost, getProgram: () => Program): SourceMapper; +} declare namespace ts { function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[]; } @@ -11967,7 +11987,7 @@ declare namespace ts { */ readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; /** - * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules + * Read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules */ readFile(fileName: string): string | undefined; realpath?(path: string): string; @@ -12317,6 +12337,7 @@ declare namespace ts.server.protocol { DefinitionAndBoundSpanFull = "definitionAndBoundSpan-full", Implementation = "implementation", ImplementationFull = "implementation-full", + EmitOutput = "emit-output", Exit = "exit", Format = "format", Formatonkey = "formatonkey", @@ -12639,6 +12660,17 @@ declare namespace ts.server.protocol { interface DefinitionRequest extends FileLocationRequest { command: CommandTypes.Definition; } + interface DefinitionAndBoundSpanRequest extends FileLocationRequest { + readonly command: CommandTypes.DefinitionAndBoundSpan; + } + interface DefinitionAndBoundSpanResponse extends Response { + readonly body: DefinitionInfoAndBoundSpan; + } + interface EmitOutputRequest extends FileRequest { + } + interface EmitOutputResponse extends Response { + readonly body: EmitOutput; + } interface TypeDefinitionRequest extends FileLocationRequest { command: CommandTypes.TypeDefinition; } @@ -12737,6 +12769,13 @@ declare namespace ts.server.protocol { command: CommandTypes.Rename; arguments: RenameRequestArgs; } + interface RenameFullRequest extends FileLocationRequest { + readonly command: CommandTypes.RenameLocationsFull; + readonly arguments: RenameRequestArgs; + } + interface RenameFullResponse extends Response { + readonly body: ReadonlyArray; + } interface RenameInfo { canRename: boolean; localizedErrorMessage?: string; @@ -13627,7 +13666,7 @@ declare namespace ts.server { getCompilerOptions(): CompilerOptions; getNewLine(): string; getProjectVersion(): string; - getProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): ReadonlyArray; getScriptFileNames(): string[]; private getOrCreateScriptInfoAndAttachToProject; getScriptKind(fileName: string): ScriptKind; @@ -13659,6 +13698,7 @@ declare namespace ts.server { getGlobalProjectErrors(): ReadonlyArray; getAllProjectErrors(): ReadonlyArray; getLanguageService(ensureSynchronized?: boolean): LanguageService; + getSourceMapper(): SourceMapper; private shouldEmitFile; getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; @@ -13741,7 +13781,7 @@ declare namespace ts.server { updateGraph(): boolean; getCachedDirectoryStructureHost(): CachedDirectoryStructureHost; getConfigFilePath(): NormalizedPath; - getProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): ReadonlyArray; updateReferences(refs: ReadonlyArray | undefined): void; enablePlugins(): void; getGlobalProjectErrors(): ReadonlyArray; @@ -14017,8 +14057,8 @@ declare namespace ts.server { getSymlinkedProjects(info: ScriptInfo): MultiMap | undefined; private watchClosedScriptInfo; private stopWatchingScriptInfo; - getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined, hostToQueryFileExistsOn: DirectoryStructureHost | undefined): ScriptInfo | undefined; - getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, fileContent: string | undefined, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined): ScriptInfo | undefined; + private getOrCreateScriptInfoNotOpenedByClientForNormalizedPath; + private getOrCreateScriptInfoOpenedByClientForNormalizedPath; getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, hostToQueryFileExistsOn?: { fileExists(path: string): boolean; }): ScriptInfo | undefined; @@ -14033,6 +14073,11 @@ declare namespace ts.server { private removeRootOfInferredProjectIfNowPartOfOtherProject; private ensureProjectForOpenFiles; openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind, projectRootPath?: string): OpenConfiguredProjectResult; + getProjectForFileWithoutOpening(fileName: NormalizedPath): { + readonly scriptInfo: ScriptInfo; + readonly projects: ReadonlyArray; + } | undefined; + fileExists(fileName: NormalizedPath): boolean; private findExternalProjectContainingOpenScriptInfo; openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult; private telemetryOnOpenFile; @@ -14130,11 +14175,14 @@ declare namespace ts.server { private convertToDiagnosticsWithLinePosition; private getDiagnosticsWorker; private getDefinition; + private mapDefinitionInfoLocations; private getDefinitionAndBoundSpan; + private getEmitOutput; private mapDefinitionInfo; private static mapToOriginalLocation; private toFileSpan; private getTypeDefinition; + private mapImplementationLocations; private getImplementation; private getOccurrences; private getSyntacticDiagnosticsSync; @@ -14149,6 +14197,8 @@ declare namespace ts.server { private getProjects; private getDefaultProject; private getRenameLocations; + private static mapRenameInfo; + private toSpanGroups; private getReferences; private openClientFile; private getPosition; @@ -14187,6 +14237,7 @@ declare namespace ts.server { private toLocationTextSpan; private getNavigationTree; private getNavigateToItems; + private getFullNavigateToItems; private getSupportedCodeFixes; private isLocation; private extractPositionAndRange; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 60f44a00576..f20c70e0095 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1822,7 +1822,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -4140,10 +4139,14 @@ declare namespace ts { * @returns A 'Program' object. */ function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; + interface ResolveProjectReferencePathHost { + fileExists(fileName: string): boolean; + } /** - * Returns the target config filename of a project reference + * Returns the target config filename of a project reference. + * Note: The file might not exist. */ - function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName; + function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; } declare namespace ts { interface EmitOutput { diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols index 5d9aa8c53c5..ca9b9a93444 100644 --- a/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols @@ -24,7 +24,7 @@ x( // come comment // some other comment -// @anohter +// @another x(); >x : Symbol(x, Decl(a.js, 0, 3)) diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.types b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types index a07bf43901b..953a4f4b910 100644 --- a/tests/baselines/reference/checkJsFiles_skipDiagnostics.types +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types @@ -31,7 +31,7 @@ x( // come comment // some other comment -// @anohter +// @another x(); >x() : any diff --git a/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline b/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline index e01194874bf..80a31656fd0 100644 --- a/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline +++ b/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline @@ -4,6 +4,7 @@ Diagnostics: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. EmitSkipped: false + FileName : /tests/cases/fourslash/a.js function foo2() { return 30; } // no error - should emit a.js diff --git a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js new file mode 100644 index 00000000000..c1c676b1137 --- /dev/null +++ b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js @@ -0,0 +1,27 @@ +//// [constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts] +// https://github.com/Microsoft/TypeScript/issues/25379 + +interface Map { + // ... +} + +export type ImmutableTypes = IImmutableMap; + +export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; + +export interface IImmutableMap> extends Map { + set(key: K, value: T[K]): IImmutableMap; +} + +export type ImmutableTypes2 = IImmutableMap2; +type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; +export type ImmutableModel2 = { [K in keyof T]: isImmutableType }; +export interface IImmutableMap2> extends Map { + set(key: K, value: T[K]): IImmutableMap2; +} + + +//// [constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js] +"use strict"; +// https://github.com/Microsoft/TypeScript/issues/25379 +exports.__esModule = true; diff --git a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.symbols b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.symbols new file mode 100644 index 00000000000..b60d7a05ae6 --- /dev/null +++ b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.symbols @@ -0,0 +1,86 @@ +=== tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts === +// https://github.com/Microsoft/TypeScript/issues/25379 + +interface Map { +>Map : Symbol(Map, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 0, 0)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 2, 14)) +>V : Symbol(V, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 2, 16)) + + // ... +} + +export type ImmutableTypes = IImmutableMap; +>ImmutableTypes : Symbol(ImmutableTypes, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 4, 1)) +>IImmutableMap : Symbol(IImmutableMap, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 95)) + +export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; +>ImmutableModel : Symbol(ImmutableModel, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 6, 48)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 35)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 27)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 35)) +>ImmutableTypes : Symbol(ImmutableTypes, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 4, 1)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 35)) + +export interface IImmutableMap> extends Map { +>IImmutableMap : Symbol(IImmutableMap, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 95)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +>ImmutableModel : Symbol(ImmutableModel, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 6, 48)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +>Map : Symbol(Map, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 0, 0)) + + set(key: K, value: T[K]): IImmutableMap; +>set : Symbol(IImmutableMap.set, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 86)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 8)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +>key : Symbol(key, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 8)) +>value : Symbol(value, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 34)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 8)) +>IImmutableMap : Symbol(IImmutableMap, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 95)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +} + +export type ImmutableTypes2 = IImmutableMap2; +>ImmutableTypes2 : Symbol(ImmutableTypes2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 12, 1)) +>IImmutableMap2 : Symbol(IImmutableMap2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 75)) + +type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; +>isImmutableType : Symbol(isImmutableType, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 14, 50)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 21)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 21)) +>ImmutableTypes2 : Symbol(ImmutableTypes2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 12, 1)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 21)) + +export type ImmutableModel2 = { [K in keyof T]: isImmutableType }; +>ImmutableModel2 : Symbol(ImmutableModel2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 68)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 28)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 36)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 28)) +>isImmutableType : Symbol(isImmutableType, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 14, 50)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 28)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 36)) + +export interface IImmutableMap2> extends Map { +>IImmutableMap2 : Symbol(IImmutableMap2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 75)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +>ImmutableModel2 : Symbol(ImmutableModel2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 68)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +>Map : Symbol(Map, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 0, 0)) + + set(key: K, value: T[K]): IImmutableMap2; +>set : Symbol(IImmutableMap2.set, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 88)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 8)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +>key : Symbol(key, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 8)) +>value : Symbol(value, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 34)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 8)) +>IImmutableMap2 : Symbol(IImmutableMap2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 75)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +} + diff --git a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types new file mode 100644 index 00000000000..1e9d3f99e21 --- /dev/null +++ b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types @@ -0,0 +1,86 @@ +=== tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts === +// https://github.com/Microsoft/TypeScript/issues/25379 + +interface Map { +>Map : Map +>K : K +>V : V + + // ... +} + +export type ImmutableTypes = IImmutableMap; +>ImmutableTypes : IImmutableMap +>IImmutableMap : IImmutableMap + +export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; +>ImmutableModel : ImmutableModel +>T : T +>K : K +>T : T +>T : T +>K : K +>ImmutableTypes : IImmutableMap +>T : T +>K : K + +export interface IImmutableMap> extends Map { +>IImmutableMap : IImmutableMap +>T : T +>ImmutableModel : ImmutableModel +>T : T +>Map : Map + + set(key: K, value: T[K]): IImmutableMap; +>set : (key: K, value: T[K]) => IImmutableMap +>K : K +>T : T +>key : K +>K : K +>value : T[K] +>T : T +>K : K +>IImmutableMap : IImmutableMap +>T : T +} + +export type ImmutableTypes2 = IImmutableMap2; +>ImmutableTypes2 : IImmutableMap2 +>IImmutableMap2 : IImmutableMap2 + +type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; +>isImmutableType : isImmutableType +>T : T +>T : T +>ImmutableTypes2 : IImmutableMap2 +>T : T + +export type ImmutableModel2 = { [K in keyof T]: isImmutableType }; +>ImmutableModel2 : ImmutableModel2 +>T : T +>K : K +>T : T +>isImmutableType : isImmutableType +>T : T +>K : K + +export interface IImmutableMap2> extends Map { +>IImmutableMap2 : IImmutableMap2 +>T : T +>ImmutableModel2 : ImmutableModel2 +>T : T +>Map : Map + + set(key: K, value: T[K]): IImmutableMap2; +>set : (key: K, value: T[K]) => IImmutableMap2 +>K : K +>T : T +>key : K +>K : K +>value : T[K] +>T : T +>K : K +>IImmutableMap2 : IImmutableMap2 +>T : T +} + diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping.baseline deleted file mode 100644 index 5fae8ec8c99..00000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping.baseline +++ /dev/null @@ -1,34 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -FileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../tests/cases/fourslash/index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping2.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping2.baseline deleted file mode 100644 index 151713a03bd..00000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping2.baseline +++ /dev/null @@ -1,35 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js.map -{"version":3,"file":"index.js","sourceRoot":"/tests/cases/fourslash/","sources":["index.ts"],"names":[],"mappings":";;AAAA;IAAA;IASA,CAAC;IAPG,wBAAU,GAAV,UAAW,QAAkB,IAAS,CAAC;IACvC,yBAAW,GAAX;QACI,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;YACrB,OAAO,EAAC,CAAC,EAAE,EAAE,EAAC,CAAC;SAClB;QACD,OAAO,EAAC,CAAC,EAAE,KAAK,EAAC,CAAC;IACtB,CAAC;IACL,UAAC;AAAD,CAAC,AATD,IASC;AATY,kBAAG"}FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -//# sourceMappingURL=index.js.mapFileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"/tests/cases/fourslash/","sources":["index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping3.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping3.baseline deleted file mode 100644 index f05cbbd4c35..00000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping3.baseline +++ /dev/null @@ -1,34 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -FileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"/tests/cases/fourslash/","sources":["index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInline.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInline.baseline deleted file mode 100644 index ad51be6ddc0..00000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInline.baseline +++ /dev/null @@ -1,34 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90ZXN0cy9jYXNlcy9mb3Vyc2xhc2gvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTtJQUFBO0lBU0EsQ0FBQztJQVBHLHdCQUFVLEdBQVYsVUFBVyxRQUFrQixJQUFTLENBQUM7SUFDdkMseUJBQVcsR0FBWDtRQUNJLElBQUksSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLEdBQUcsRUFBRTtZQUNyQixPQUFPLEVBQUMsQ0FBQyxFQUFFLEVBQUUsRUFBQyxDQUFDO1NBQ2xCO1FBQ0QsT0FBTyxFQUFDLENBQUMsRUFBRSxLQUFLLEVBQUMsQ0FBQztJQUN0QixDQUFDO0lBQ0wsVUFBQztBQUFELENBQUMsQUFURCxJQVNDO0FBVFksa0JBQUcifQ==FileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../tests/cases/fourslash/index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInlineSources.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInlineSources.baseline deleted file mode 100644 index 8f6440b29dc..00000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInlineSources.baseline +++ /dev/null @@ -1,34 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90ZXN0cy9jYXNlcy9mb3Vyc2xhc2gvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTtJQUFBO0lBU0EsQ0FBQztJQVBHLHdCQUFVLEdBQVYsVUFBVyxRQUFrQixJQUFTLENBQUM7SUFDdkMseUJBQVcsR0FBWDtRQUNJLElBQUksSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLEdBQUcsRUFBRTtZQUNyQixPQUFPLEVBQUMsQ0FBQyxFQUFFLEVBQUUsRUFBQyxDQUFDO1NBQ2xCO1FBQ0QsT0FBTyxFQUFDLENBQUMsRUFBRSxLQUFLLEVBQUMsQ0FBQztJQUN0QixDQUFDO0lBQ0wsVUFBQztBQUFELENBQUMsQUFURCxJQVNDO0FBVFksa0JBQUciLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY2xhc3MgRm9vIHtcbiAgICBtZW1iZXI6IHN0cmluZztcbiAgICBtZXRob2ROYW1lKHByb3BOYW1lOiBTb21lVHlwZSk6IHZvaWQge31cbiAgICBvdGhlck1ldGhvZCgpIHtcbiAgICAgICAgaWYgKE1hdGgucmFuZG9tKCkgPiAwLjUpIHtcbiAgICAgICAgICAgIHJldHVybiB7eDogNDJ9O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7eTogXCJ5ZXNcIn07XG4gICAgfVxufVxuXG5leHBvcnQgaW50ZXJmYWNlIFNvbWVUeXBlIHtcbiAgICBtZW1iZXI6IG51bWJlcjtcbn0iXX0=FileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../tests/cases/fourslash/index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/duplicatePackage_globalMerge.errors.txt b/tests/baselines/reference/duplicatePackage_globalMerge.errors.txt new file mode 100644 index 00000000000..d7e77340ac1 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_globalMerge.errors.txt @@ -0,0 +1,31 @@ +/node_modules/@types/react/index.d.ts(1,9): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. +/src/index.ts(1,24): error TS2306: File '/node_modules/@types/react/index.d.ts' is not a module. +/tests/index.ts(1,24): error TS2306: File '/tests/node_modules/@types/react/index.d.ts' is not a module. + + +==== /src/bug25410.ts (0 errors) ==== + import { x } from './index' + import { y } from '../tests/index' + +==== /src/index.ts (1 errors) ==== + import * as React from 'react'; + ~~~~~~~ +!!! error TS2306: File '/node_modules/@types/react/index.d.ts' is not a module. + export var x = 1 +==== /tests/index.ts (1 errors) ==== + import * as React from 'react'; + ~~~~~~~ +!!! error TS2306: File '/tests/node_modules/@types/react/index.d.ts' is not a module. + export var y = 2 + +==== /tests/node_modules/@types/react/package.json (0 errors) ==== + { "name": "@types/react", "version": "16.4.6" } +==== /tests/node_modules/@types/react/index.d.ts (0 errors) ==== + +==== /node_modules/@types/react/package.json (0 errors) ==== + { "name": "@types/react", "version": "16.4.6" } +==== /node_modules/@types/react/index.d.ts (1 errors) ==== + declare global { } + ~~~~~~ +!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + \ No newline at end of file diff --git a/tests/baselines/reference/duplicatePackage_globalMerge.js b/tests/baselines/reference/duplicatePackage_globalMerge.js new file mode 100644 index 00000000000..6f12995e022 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_globalMerge.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/duplicatePackage_globalMerge.ts] //// + +//// [index.ts] +import * as React from 'react'; +export var x = 1 +//// [index.ts] +import * as React from 'react'; +export var y = 2 + +//// [package.json] +{ "name": "@types/react", "version": "16.4.6" } +//// [index.d.ts] + +//// [package.json] +{ "name": "@types/react", "version": "16.4.6" } +//// [index.d.ts] +declare global { } + +//// [bug25410.ts] +import { x } from './index' +import { y } from '../tests/index' + + +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.x = 1; +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.y = 2; +//// [bug25410.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/duplicatePackage_globalMerge.symbols b/tests/baselines/reference/duplicatePackage_globalMerge.symbols new file mode 100644 index 00000000000..d17be9ae855 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_globalMerge.symbols @@ -0,0 +1,29 @@ +=== /src/bug25410.ts === +import { x } from './index' +>x : Symbol(x, Decl(bug25410.ts, 0, 8)) + +import { y } from '../tests/index' +>y : Symbol(y, Decl(bug25410.ts, 1, 8)) + +=== /src/index.ts === +import * as React from 'react'; +>React : Symbol(React, Decl(index.ts, 0, 6)) + +export var x = 1 +>x : Symbol(x, Decl(index.ts, 1, 10)) + +=== /tests/index.ts === +import * as React from 'react'; +>React : Symbol(React, Decl(index.ts, 0, 6)) + +export var y = 2 +>y : Symbol(y, Decl(index.ts, 1, 10)) + +=== /tests/node_modules/@types/react/index.d.ts === + +>global : Symbol(global, Decl(index.d.ts, 0, 0)) + +=== /node_modules/@types/react/index.d.ts === +declare global { } +>global : Symbol(global, Decl(index.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/duplicatePackage_globalMerge.types b/tests/baselines/reference/duplicatePackage_globalMerge.types new file mode 100644 index 00000000000..b558538be3d --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_globalMerge.types @@ -0,0 +1,31 @@ +=== /src/bug25410.ts === +import { x } from './index' +>x : number + +import { y } from '../tests/index' +>y : number + +=== /src/index.ts === +import * as React from 'react'; +>React : any + +export var x = 1 +>x : number +>1 : 1 + +=== /tests/index.ts === +import * as React from 'react'; +>React : any + +export var y = 2 +>y : number +>2 : 2 + +=== /tests/node_modules/@types/react/index.d.ts === + +>global : typeof global + +=== /node_modules/@types/react/index.d.ts === +declare global { } +>global : typeof global + diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 174aff77424..be4cb35bcb5 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -141,7 +141,7 @@ namespace N { >T5 : T5 } export declare type T7 = { ->T7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>T7 : T7 [N.c2]: number; >[N.c2] : number diff --git a/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.js b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.js new file mode 100644 index 00000000000..18011cbcc13 --- /dev/null +++ b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/exportAssignedNamespaceIsVisibleInDeclarationEmit.ts] //// + +//// [thing.d.ts] +declare namespace Foo { + export interface Bar {} + export function f(): Bar; +} +export = Foo; +//// [index.ts] +import { f } from "./thing"; +export const thing = f(); + +//// [index.js] +"use strict"; +exports.__esModule = true; +var thing_1 = require("./thing"); +exports.thing = thing_1.f(); + + +//// [index.d.ts] +export declare const thing: import("./thing").Bar; diff --git a/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.symbols b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.symbols new file mode 100644 index 00000000000..1f5fd46cf57 --- /dev/null +++ b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/thing.d.ts === +declare namespace Foo { +>Foo : Symbol(Foo, Decl(thing.d.ts, 0, 0)) + + export interface Bar {} +>Bar : Symbol(Bar, Decl(thing.d.ts, 0, 23)) + + export function f(): Bar; +>f : Symbol(f, Decl(thing.d.ts, 1, 27)) +>Bar : Symbol(Bar, Decl(thing.d.ts, 0, 23)) +} +export = Foo; +>Foo : Symbol(Foo, Decl(thing.d.ts, 0, 0)) + +=== tests/cases/compiler/index.ts === +import { f } from "./thing"; +>f : Symbol(f, Decl(index.ts, 0, 8)) + +export const thing = f(); +>thing : Symbol(thing, Decl(index.ts, 1, 12)) +>f : Symbol(f, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.types b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.types new file mode 100644 index 00000000000..5dfd9611cca --- /dev/null +++ b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/thing.d.ts === +declare namespace Foo { +>Foo : typeof Foo + + export interface Bar {} +>Bar : Bar + + export function f(): Bar; +>f : () => Bar +>Bar : Bar +} +export = Foo; +>Foo : typeof Foo + +=== tests/cases/compiler/index.ts === +import { f } from "./thing"; +>f : () => import("tests/cases/compiler/thing").Bar + +export const thing = f(); +>thing : import("tests/cases/compiler/thing").Bar +>f() : import("tests/cases/compiler/thing").Bar +>f : () => import("tests/cases/compiler/thing").Bar + diff --git a/tests/baselines/reference/getEmitOutput-pp.baseline b/tests/baselines/reference/getEmitOutput-pp.baseline index 82243870b29..d3e9e977f58 100644 --- a/tests/baselines/reference/getEmitOutput-pp.baseline +++ b/tests/baselines/reference/getEmitOutput-pp.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/shims-pp/inputFile1.js var x = 5; var Bar = /** @class */ (function () { @@ -6,6 +7,7 @@ var Bar = /** @class */ (function () { } return Bar; }()); + FileName : /tests/cases/fourslash/shims-pp/inputFile1.d.ts declare var x: number; declare class Bar { @@ -14,6 +16,7 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/shims-pp/inputFile2.js var x1 = "hello world"; var Foo = /** @class */ (function () { @@ -21,6 +24,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : /tests/cases/fourslash/shims-pp/inputFile2.d.ts declare var x1: string; declare class Foo { diff --git a/tests/baselines/reference/getEmitOutput.baseline b/tests/baselines/reference/getEmitOutput.baseline index 9fa32d4dfe8..1b029eefd12 100644 --- a/tests/baselines/reference/getEmitOutput.baseline +++ b/tests/baselines/reference/getEmitOutput.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/shims/inputFile1.js var x = 5; var Bar = /** @class */ (function () { @@ -6,6 +7,7 @@ var Bar = /** @class */ (function () { } return Bar; }()); + FileName : /tests/cases/fourslash/shims/inputFile1.d.ts declare var x: number; declare class Bar { @@ -14,6 +16,7 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/shims/inputFile2.js var x1 = "hello world"; var Foo = /** @class */ (function () { @@ -21,6 +24,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : /tests/cases/fourslash/shims/inputFile2.d.ts declare var x1: string; declare class Foo { diff --git a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline index ac2d4850bb4..9208d6fb4f9 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js var x = 5; var Bar = /** @class */ (function () { @@ -6,6 +7,7 @@ var Bar = /** @class */ (function () { } return Bar; }()); + FileName : /tests/cases/fourslash/inputFile1.d.ts declare var x: number; declare class Bar { @@ -14,6 +16,7 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js var x1 = "hello world"; var Foo = /** @class */ (function () { @@ -21,6 +24,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : /tests/cases/fourslash/inputFile2.d.ts declare var x1: string; declare class Foo { diff --git a/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline b/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline index 18e8920ba72..0e19223306a 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingleFile.js var x = 5; var Bar = /** @class */ (function () { @@ -12,6 +13,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : declSingleFile.d.ts declare var x: number; declare class Bar { diff --git a/tests/baselines/reference/getEmitOutputExternalModule.baseline b/tests/baselines/reference/getEmitOutputExternalModule.baseline index bd4162854f8..c577fb56792 100644 --- a/tests/baselines/reference/getEmitOutputExternalModule.baseline +++ b/tests/baselines/reference/getEmitOutputExternalModule.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingleFile.js var x = 5; var Bar = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputExternalModule2.baseline b/tests/baselines/reference/getEmitOutputExternalModule2.baseline index 3aff8629acf..dfbe9bf061d 100644 --- a/tests/baselines/reference/getEmitOutputExternalModule2.baseline +++ b/tests/baselines/reference/getEmitOutputExternalModule2.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingleFile.js var x = 5; var Bar = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputMapRoots.baseline b/tests/baselines/reference/getEmitOutputMapRoots.baseline index 4b4a9b0395b..67a136a3456 100644 --- a/tests/baselines/reference/getEmitOutputMapRoots.baseline +++ b/tests/baselines/reference/getEmitOutputMapRoots.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : declSingleFile.js.map -{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : declSingleFile.js +{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : declSingleFile.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputNoErrors.baseline b/tests/baselines/reference/getEmitOutputNoErrors.baseline index 8cf9b0f143d..8dea3c96fe6 100644 --- a/tests/baselines/reference/getEmitOutputNoErrors.baseline +++ b/tests/baselines/reference/getEmitOutputNoErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var x; var M = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline index b913e00e798..e37174aa232 100644 --- a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline +++ b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js var x; var Foo = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputOut.baseline b/tests/baselines/reference/getEmitOutputOut.baseline index 9508b6d5570..26bb4e1b693 100644 --- a/tests/baselines/reference/getEmitOutputOut.baseline +++ b/tests/baselines/reference/getEmitOutputOut.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : out.js /// var foo; diff --git a/tests/baselines/reference/getEmitOutputOutFile.baseline b/tests/baselines/reference/getEmitOutputOutFile.baseline index c683d963f0e..ce3454c4ed4 100644 --- a/tests/baselines/reference/getEmitOutputOutFile.baseline +++ b/tests/baselines/reference/getEmitOutputOutFile.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : outFile.js var x = 5; var Bar = /** @class */ (function () { @@ -12,6 +13,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : outFile.d.ts declare var x: number; declare class Bar { diff --git a/tests/baselines/reference/getEmitOutputSingleFile.baseline b/tests/baselines/reference/getEmitOutputSingleFile.baseline index fd370667bc5..929cd9d7a7d 100644 --- a/tests/baselines/reference/getEmitOutputSingleFile.baseline +++ b/tests/baselines/reference/getEmitOutputSingleFile.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : outputDir/singleFile.js var x; var Bar = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputSingleFile2.baseline b/tests/baselines/reference/getEmitOutputSingleFile2.baseline index 18e8920ba72..0e19223306a 100644 --- a/tests/baselines/reference/getEmitOutputSingleFile2.baseline +++ b/tests/baselines/reference/getEmitOutputSingleFile2.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingleFile.js var x = 5; var Bar = /** @class */ (function () { @@ -12,6 +13,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : declSingleFile.d.ts declare var x: number; declare class Bar { diff --git a/tests/baselines/reference/getEmitOutputSourceMap.baseline b/tests/baselines/reference/getEmitOutputSourceMap.baseline index e1e65087e6d..5ef3f843b23 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js.map -{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile.js +{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputSourceMap2.baseline b/tests/baselines/reference/getEmitOutputSourceMap2.baseline index ccd11b1fec0..f9a3455ba77 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap2.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap2.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : sample/outDir/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : sample/outDir/inputFile1.js +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : sample/outDir/inputFile1.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { @@ -10,8 +12,10 @@ var M = /** @class */ (function () { }()); //# sourceMappingURL=inputFile1.js.map EmitSkipped: false + FileName : sample/outDir/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,IAAI,KAAK,KAAK,SAAS,EAAE;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC;CACb"}FileName : sample/outDir/inputFile2.js +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,IAAI,KAAK,KAAK,SAAS,EAAE;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC;CACb"} +FileName : sample/outDir/inputFile2.js var intro = "hello world"; if (intro !== undefined) { var k = 10; diff --git a/tests/baselines/reference/getEmitOutputSourceRoot.baseline b/tests/baselines/reference/getEmitOutputSourceRoot.baseline index ddd6568b704..a5185984a6f 100644 --- a/tests/baselines/reference/getEmitOutputSourceRoot.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRoot.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js.map -{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile.js +{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline index f6d9cb184e6..a8013f697ca 100644 --- a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js +{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile1.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { @@ -10,8 +12,10 @@ var M = /** @class */ (function () { }()); //# sourceMappingURL=inputFile1.js.map EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile2.js +{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile2.js var bar = "hello world Typescript"; var C = /** @class */ (function () { function C() { diff --git a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline index 5a045503708..0e15fe43aca 100644 --- a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline +++ b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile1.js // regular ts file var t = 5; var Bar = /** @class */ (function () { @@ -8,7 +10,8 @@ var Bar = /** @class */ (function () { } return Bar; }()); -//# sourceMappingURL=inputFile1.js.mapFileName : /tests/cases/fourslash/inputFile1.d.ts +//# sourceMappingURL=inputFile1.js.map +FileName : /tests/cases/fourslash/inputFile1.d.ts declare var t: number; declare class Bar { x: string; @@ -16,11 +19,14 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.jsx.map -{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : /tests/cases/fourslash/inputFile2.jsx +{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"} +FileName : /tests/cases/fourslash/inputFile2.jsx var y = "my div"; var x =
; -//# sourceMappingURL=inputFile2.jsx.mapFileName : /tests/cases/fourslash/inputFile2.d.ts +//# sourceMappingURL=inputFile2.jsx.map +FileName : /tests/cases/fourslash/inputFile2.d.ts declare var y: string; declare var x: any; diff --git a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline index 4f5b8f65d22..071d18992ea 100644 --- a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline +++ b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile1.js // regular ts file var t = 5; var Bar = /** @class */ (function () { @@ -8,7 +10,8 @@ var Bar = /** @class */ (function () { } return Bar; }()); -//# sourceMappingURL=inputFile1.js.mapFileName : /tests/cases/fourslash/inputFile1.d.ts +//# sourceMappingURL=inputFile1.js.map +FileName : /tests/cases/fourslash/inputFile1.d.ts declare var t: number; declare class Bar { x: string; @@ -16,11 +19,14 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,6BAAK,IAAI,EAAG,CAAC,GAAI,CAAA"}FileName : /tests/cases/fourslash/inputFile2.js +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,6BAAK,IAAI,EAAG,CAAC,GAAI,CAAA"} +FileName : /tests/cases/fourslash/inputFile2.js var y = "my div"; var x = React.createElement("div", { name: y }); -//# sourceMappingURL=inputFile2.js.mapFileName : /tests/cases/fourslash/inputFile2.d.ts +//# sourceMappingURL=inputFile2.js.map +FileName : /tests/cases/fourslash/inputFile2.d.ts declare var React: any; declare var y: string; declare var x: any; diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline index fa07a2af00e..0176f4b628f 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline @@ -1,6 +1,7 @@ EmitSkipped: false EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js var x1 = "hello world"; var Foo = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline index b22067dc318..86a6519b4b0 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline @@ -1,6 +1,7 @@ EmitSkipped: false EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -12,6 +13,7 @@ var Foo = /** @class */ (function () { exports.Foo = Foo; EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile3.js var x = "hello"; diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline index 1ce3d9f33c3..cd1f2739e33 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingle.js var x = "hello"; var x1 = 1000; diff --git a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline index 6609554a299..b011e5885e3 100644 --- a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js // File contains early errors. All outputs should be skipped. var uninitialized_const_error; diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline index d2b26ca48c8..7ad60f361bb 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var M; (function (M) { @@ -9,6 +10,7 @@ var M; }()); M.foo = new C(); })(M || (M = {})); + FileName : /tests/cases/fourslash/inputFile.d.ts declare module M { class C { diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline index 77131f89dd5..46ba9652cc7 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js define(["require", "exports"], function (require, exports) { "use strict"; @@ -13,6 +14,7 @@ define(["require", "exports"], function (require, exports) { M.foo = new C(); })(M = exports.M || (exports.M = {})); }); + FileName : /tests/cases/fourslash/inputFile.d.ts class C { } diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline index 55a58ea041f..7ada814a55e 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var x = "hello world"; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline index b5848da3457..739ef233191 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var x = "hello world"; + FileName : /tests/cases/fourslash/inputFile.d.ts declare var x: number; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline index 4c22a7e3f93..2fb3cdd9210 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline @@ -1,8 +1,10 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js // File to emit, does not contain semantic errors // expected to be emitted correctelly regardless of the semantic errors in the other file var noErrors = true; + FileName : /tests/cases/fourslash/inputFile1.d.ts declare var noErrors: boolean; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline index 6a58015c1b3..0d5ab3f6747 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline @@ -1,10 +1,12 @@ EmitSkipped: false + FileName : out.js // File to emit, does not contain semantic errors, but --out is passed // expected to not generate declarations because of the semantic errors in the other file var noErrors = true; // File not emitted, and contains semantic errors var semanticError = "string"; + FileName : out.d.ts declare var noErrors: boolean; declare var semanticError: boolean; diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline index f51782cc75d..1ec89e66d5a 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js // File to emit, does not contain syntactic errors // expected to be emitted correctelly regardless of the syntactic errors in the other file diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline index 0f526b85b4f..f429d4e1295 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : out.js // File to emit, does not contain syntactic errors, but --out is passed // expected to not generate outputs because of the syntactic errors in the other file. diff --git a/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline b/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline index 8aa81ba60ce..f84b9e810c9 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var x; diff --git a/tests/baselines/reference/importTypeInJSDoc.types b/tests/baselines/reference/importTypeInJSDoc.types index d76f7aac6f6..3f905c967b8 100644 --- a/tests/baselines/reference/importTypeInJSDoc.types +++ b/tests/baselines/reference/importTypeInJSDoc.types @@ -59,8 +59,8 @@ a = new Foo({doer: Foo.Bar}); >Bar : (x: string, y?: number) => void const q = /** @type {import("./externs").Bar} */({ doer: q => q }); ->q : MyClass.Bar ->({ doer: q => q }) : MyClass.Bar +>q : import("tests/cases/conformance/types/import/externs").Bar +>({ doer: q => q }) : import("tests/cases/conformance/types/import/externs").Bar >{ doer: q => q } : { doer: (q: string) => string; } >doer : (q: string) => string >q => q : (q: string) => string diff --git a/tests/baselines/reference/importUsedAsTypeWithErrors.errors.txt b/tests/baselines/reference/importUsedAsTypeWithErrors.errors.txt new file mode 100644 index 00000000000..7d86ce7624a --- /dev/null +++ b/tests/baselines/reference/importUsedAsTypeWithErrors.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/main.ts(1,17): error TS1340: Module './test' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./test')'? + + +==== tests/cases/compiler/test.ts (0 errors) ==== + export interface T { + value: string + } + +==== tests/cases/compiler/main.ts (1 errors) ==== + export const a: import("./test") = null; + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './test' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./test')'? + \ No newline at end of file diff --git a/tests/baselines/reference/importUsedAsTypeWithErrors.js b/tests/baselines/reference/importUsedAsTypeWithErrors.js new file mode 100644 index 00000000000..add7e6b2852 --- /dev/null +++ b/tests/baselines/reference/importUsedAsTypeWithErrors.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/importUsedAsTypeWithErrors.ts] //// + +//// [test.ts] +export interface T { + value: string +} + +//// [main.ts] +export const a: import("./test") = null; + + +//// [test.js] +"use strict"; +exports.__esModule = true; +//// [main.js] +"use strict"; +exports.__esModule = true; +exports.a = null; diff --git a/tests/baselines/reference/importUsedAsTypeWithErrors.symbols b/tests/baselines/reference/importUsedAsTypeWithErrors.symbols new file mode 100644 index 00000000000..b6d4017ea6c --- /dev/null +++ b/tests/baselines/reference/importUsedAsTypeWithErrors.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/test.ts === +export interface T { +>T : Symbol(T, Decl(test.ts, 0, 0)) + + value: string +>value : Symbol(T.value, Decl(test.ts, 0, 20)) +} + +=== tests/cases/compiler/main.ts === +export const a: import("./test") = null; +>a : Symbol(a, Decl(main.ts, 0, 12)) + diff --git a/tests/baselines/reference/importUsedAsTypeWithErrors.types b/tests/baselines/reference/importUsedAsTypeWithErrors.types new file mode 100644 index 00000000000..a41de4f658e --- /dev/null +++ b/tests/baselines/reference/importUsedAsTypeWithErrors.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/test.ts === +export interface T { +>T : T + + value: string +>value : string +} + +=== tests/cases/compiler/main.ts === +export const a: import("./test") = null; +>a : any +>null : null + diff --git a/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.errors.txt b/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.errors.txt index 5300c97a576..ac068bfba74 100644 --- a/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.errors.txt +++ b/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.errors.txt @@ -1,11 +1,17 @@ +tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts(2,24): error TS2313: Type parameter 'T' has a circular constraint. tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts(2,32): error TS2313: Type parameter 'P' has a circular constraint. +tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts(3,5): error TS2365: Operator '+=' cannot be applied to types 'number' and 'T[K]'. -==== tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts (1 errors) ==== +==== tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts (3 errors) ==== // #17847 function sum(n: number, v: T, k: K) { + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2313: Type parameter 'T' has a circular constraint. ~ !!! error TS2313: Type parameter 'P' has a circular constraint. n += v[k]; + ~~~~~~~~~ +!!! error TS2365: Operator '+=' cannot be applied to types 'number' and 'T[K]'. } \ No newline at end of file diff --git a/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.types b/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.types index b6589956216..a388d2b536b 100644 --- a/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.types +++ b/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.types @@ -14,7 +14,7 @@ function sum(n: number, v: T, >K : K n += v[k]; ->n += v[k] : number +>n += v[k] : any >n : number >v[k] : T[K] >v : T diff --git a/tests/baselines/reference/reactImportDropped.types b/tests/baselines/reference/reactImportDropped.types index ae8b1308c03..db3b3b8bdbe 100644 --- a/tests/baselines/reference/reactImportDropped.types +++ b/tests/baselines/reference/reactImportDropped.types @@ -36,10 +36,10 @@ declare global { === tests/cases/compiler/src/components/TabBar.js === export default React.createClass({ ->React.createClass({ render() { return ( null ); }}) : React.ClassicComponentClass ->React.createClass : (spec: any) => React.ClassicComponentClass +>React.createClass({ render() { return ( null ); }}) : import("tests/cases/compiler/react").ClassicComponentClass +>React.createClass : (spec: any) => import("tests/cases/compiler/react").ClassicComponentClass >React : typeof React ->createClass : (spec: any) => React.ClassicComponentClass +>createClass : (spec: any) => import("tests/cases/compiler/react").ClassicComponentClass >{ render() { return ( null ); }} : { render(): any; } render() { @@ -57,7 +57,7 @@ export default React.createClass({ === tests/cases/compiler/src/modules/navigation/NavigationView.js === import TabBar from '../../components/TabBar'; ->TabBar : React.ClassicComponentClass +>TabBar : import("tests/cases/compiler/react").ClassicComponentClass import {layout} from '../../utils/theme'; // <- DO NOT DROP this import >layout : any @@ -65,7 +65,7 @@ import {layout} from '../../utils/theme'; // <- DO NOT DROP this import const x = ; >x : any > : any ->TabBar : React.ClassicComponentClass +>TabBar : import("tests/cases/compiler/react").ClassicComponentClass >height : any >layout.footerHeight : any >layout : any diff --git a/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.js b/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.js new file mode 100644 index 00000000000..ea5ac25b1b5 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/requireOfJsonFileWithoutEsModuleInterop.ts] //// + +//// [file1.ts] +import * as test from "./test.json" + +//// [test.json] +{ + "a": true, + "b": "hello" +} + +//// [out/test.json] +{ + "a": true, + "b": "hello" +} +//// [out/file1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.symbols b/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.symbols new file mode 100644 index 00000000000..f84e06ec8f4 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === +import * as test from "./test.json" +>test : Symbol(test, Decl(file1.ts, 0, 6)) + +=== tests/cases/compiler/test.json === +{ + "a": true, +>"a" : Symbol("a", Decl(test.json, 0, 1)) + + "b": "hello" +>"b" : Symbol("b", Decl(test.json, 1, 14)) +} diff --git a/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.types b/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.types new file mode 100644 index 00000000000..3bd9e1d98b1 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithoutEsModuleInterop.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === +import * as test from "./test.json" +>test : { "a": boolean; "b": string; } + +=== tests/cases/compiler/test.json === +{ +>{ "a": true, "b": "hello"} : { "a": boolean; "b": string; } + + "a": true, +>"a" : boolean +>true : true + + "b": "hello" +>"b" : string +>"hello" : "hello" +} diff --git a/tests/baselines/reference/typeFromPropertyAssignment27.symbols b/tests/baselines/reference/typeFromPropertyAssignment27.symbols new file mode 100644 index 00000000000..e76f61b2bbc --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment27.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/salsa/a.js === +// mixed prototype-assignment+function declaration +function C() { this.p = 1; } +>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 28)) +>p : Symbol(C.p, Decl(a.js, 1, 14)) + +C.prototype = { q: 2 }; +>C.prototype : Symbol(C.prototype, Decl(a.js, 1, 28)) +>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 28)) +>prototype : Symbol(C.prototype, Decl(a.js, 1, 28)) +>q : Symbol(q, Decl(a.js, 2, 15)) + +const c = new C() +>c : Symbol(c, Decl(a.js, 4, 5)) +>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 28)) + +c.p +>c.p : Symbol(C.p, Decl(a.js, 1, 14)) +>c : Symbol(c, Decl(a.js, 4, 5)) +>p : Symbol(C.p, Decl(a.js, 1, 14)) + +c.q +>c.q : Symbol(q, Decl(a.js, 2, 15)) +>c : Symbol(c, Decl(a.js, 4, 5)) +>q : Symbol(q, Decl(a.js, 2, 15)) + diff --git a/tests/baselines/reference/typeFromPropertyAssignment27.types b/tests/baselines/reference/typeFromPropertyAssignment27.types new file mode 100644 index 00000000000..222bd04e74d --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment27.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/salsa/a.js === +// mixed prototype-assignment+function declaration +function C() { this.p = 1; } +>C : typeof C +>this.p = 1 : 1 +>this.p : any +>this : any +>p : any +>1 : 1 + +C.prototype = { q: 2 }; +>C.prototype = { q: 2 } : { [x: string]: any; q: number; } +>C.prototype : { [x: string]: any; } +>C : typeof C +>prototype : { [x: string]: any; } +>{ q: 2 } : { [x: string]: any; q: number; } +>q : number +>2 : 2 + +const c = new C() +>c : C & { [x: string]: any; q: number; } +>new C() : C & { [x: string]: any; q: number; } +>C : typeof C + +c.p +>c.p : number +>c : C & { [x: string]: any; q: number; } +>p : number + +c.q +>c.q : number +>c : C & { [x: string]: any; q: number; } +>q : number + diff --git a/tests/baselines/reference/typeFromPropertyAssignment28.errors.txt b/tests/baselines/reference/typeFromPropertyAssignment28.errors.txt new file mode 100644 index 00000000000..2f048840a1e --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment28.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/salsa/a.js(7,17): error TS2322: Type '{ [x: string]: any; q: number; }' is not assignable to type 'C'. + Object literal may only specify known properties, and 'q' does not exist in type 'C'. +tests/cases/conformance/salsa/a.js(11,3): error TS2339: Property 'q' does not exist on type 'C'. + + +==== tests/cases/conformance/salsa/a.js (2 errors) ==== + // mixed prototype-assignment+class declaration + class C { constructor() { this.p = 1; } } + // Property assignment does nothing. + // You have to use Object.defineProperty(C, "prototype", { q: 2 }) + // and that only works on classes with no superclass. + // (Object.defineProperty isn't recognised as a JS special assignment right now.) + C.prototype = { q: 2 }; + ~~~~ +!!! error TS2322: Type '{ [x: string]: any; q: number; }' is not assignable to type 'C'. +!!! error TS2322: Object literal may only specify known properties, and 'q' does not exist in type 'C'. + + const c = new C() + c.p + c.q + ~ +!!! error TS2339: Property 'q' does not exist on type 'C'. + \ No newline at end of file diff --git a/tests/baselines/reference/typeFromPropertyAssignment28.symbols b/tests/baselines/reference/typeFromPropertyAssignment28.symbols new file mode 100644 index 00000000000..a2997ef9180 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment28.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/salsa/a.js === +// mixed prototype-assignment+class declaration +class C { constructor() { this.p = 1; } } +>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 41)) +>this.p : Symbol(C.p, Decl(a.js, 1, 25)) +>this : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 41)) +>p : Symbol(C.p, Decl(a.js, 1, 25)) + +// Property assignment does nothing. +// You have to use Object.defineProperty(C, "prototype", { q: 2 }) +// and that only works on classes with no superclass. +// (Object.defineProperty isn't recognised as a JS special assignment right now.) +C.prototype = { q: 2 }; +>C.prototype : Symbol(C.prototype, Decl(a.js, 1, 41)) +>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 41)) +>prototype : Symbol(C.prototype, Decl(a.js, 1, 41)) +>q : Symbol(q, Decl(a.js, 6, 15)) + +const c = new C() +>c : Symbol(c, Decl(a.js, 8, 5)) +>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 41)) + +c.p +>c.p : Symbol(C.p, Decl(a.js, 1, 25)) +>c : Symbol(c, Decl(a.js, 8, 5)) +>p : Symbol(C.p, Decl(a.js, 1, 25)) + +c.q +>c : Symbol(c, Decl(a.js, 8, 5)) + diff --git a/tests/baselines/reference/typeFromPropertyAssignment28.types b/tests/baselines/reference/typeFromPropertyAssignment28.types new file mode 100644 index 00000000000..89056ee1398 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignment28.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/salsa/a.js === +// mixed prototype-assignment+class declaration +class C { constructor() { this.p = 1; } } +>C : C +>this.p = 1 : 1 +>this.p : number +>this : this +>p : number +>1 : 1 + +// Property assignment does nothing. +// You have to use Object.defineProperty(C, "prototype", { q: 2 }) +// and that only works on classes with no superclass. +// (Object.defineProperty isn't recognised as a JS special assignment right now.) +C.prototype = { q: 2 }; +>C.prototype = { q: 2 } : { [x: string]: any; q: number; } +>C.prototype : C +>C : typeof C +>prototype : C +>{ q: 2 } : { [x: string]: any; q: number; } +>q : number +>2 : 2 + +const c = new C() +>c : C +>new C() : C +>C : typeof C + +c.p +>c.p : number +>c : C +>p : number + +c.q +>c.q : any +>c : C +>q : any + diff --git a/tests/baselines/reference/user/prettier.log b/tests/baselines/reference/user/prettier.log index 4de7a61267b..6234640120e 100644 --- a/tests/baselines/reference/user/prettier.log +++ b/tests/baselines/reference/user/prettier.log @@ -71,10 +71,28 @@ src/language-vue/parser-vue.js(398,23): error TS2345: Argument of type '{ [x: st Property 'contentStart' is missing in type '{ [x: string]: any; tag: any; attrs: any; unary: any; start: any; children: never[]; }'. src/language-vue/parser-vue.js(399,9): error TS2322: Type '{ [x: string]: any; tag: any; attrs: any; unary: any; start: any; children: never[]; }' is not assignable to type '{ [x: string]: any; tag: string; attrs: never[]; unary: boolean; start: number; contentStart: num...'. src/main/core-options.js(51,43): error TS1005: '}' expected. -src/main/core-options.js(63,5): error TS2322: Type '{ cursorOffset: { since: string; category: string; type: "int"; default: number; range: { start: ...' is not assignable to type '{ [name: string]: OptionInfo; }'. - Property 'cursorOffset' is incompatible with index signature. - Type '{ since: string; category: string; type: "int"; default: number; range: { start: number; end: num...' is not assignable to type 'OptionInfo'. - Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. +src/main/core-options.js(63,5): error TS2322: Type '{ since: string; category: string; type: "int"; default: number; range: { start: number; end: num...' is not assignable to type 'OptionInfo'. + Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. +src/main/core-options.js(69,5): error TS2322: Type 'undefined' is not assignable to type 'string | number | boolean | { since: string; value: string | number | boolean; }[] | [{ value: (s...'. +src/main/core-options.js(82,5): error TS2322: Type '{ since: string; category: string; type: "boolean"; default: false; description: string; cliCateg...' is not assignable to type 'OptionInfo'. + Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. +src/main/core-options.js(92,5): error TS2322: Type '({ [x: string]: any; value: string; description: string; } | { [x: string]: any; value: string; s...' is not assignable to type 'OptionChoiceInfo'. + Property 'value' is missing in type '({ [x: string]: any; value: string; description: string; } | { [x: string]: any; value: string; s...'. +src/main/core-options.js(122,5): error TS2322: Type '{ since: string; type: "path"; array: true; default: [{ value: never[]; }]; category: string; des...' is not assignable to type 'OptionInfo'. + Object literal may only specify known properties, and 'cliName' does not exist in type 'OptionInfo'. +src/main/core-options.js(125,3): error TS2322: Type '{ since: string; category: string; type: "int"; default: number; description: string; range: { st...' is not assignable to type 'OptionInfo'. + Property 'array' is missing in type '{ since: string; category: string; type: "int"; default: number; description: string; range: { st...'. +src/main/core-options.js(144,5): error TS2322: Type '{ since: string; category: string; type: "int"; default: number; range: { start: number; end: num...' is not assignable to type 'OptionInfo'. + Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. +src/main/core-options.js(157,5): error TS2322: Type '{ since: string; category: string; type: "int"; default: number; range: { start: number; end: num...' is not assignable to type 'OptionInfo'. + Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. +src/main/core-options.js(168,5): error TS2322: Type '{ since: string; category: string; type: "boolean"; default: false; description: any; cliCategory...' is not assignable to type 'OptionInfo'. + Object literal may only specify known properties, and 'cliCategory' does not exist in type 'OptionInfo'. +src/main/core-options.js(170,3): error TS2322: Type '{ type: "int"; category: string; default: number; description: string; range: { start: number; en...' is not assignable to type 'OptionInfo'. + Property 'since' is missing in type '{ type: "int"; category: string; default: number; description: string; range: { start: number; en...'. +src/main/core-options.js(182,5): error TS2322: Type 'string' is not assignable to type 'boolean | null'. +src/main/core-options.js(187,3): error TS2322: Type '{ since: string; category: string; type: "boolean"; default: false; description: string; }' is not assignable to type 'OptionInfo'. + Property 'array' is missing in type '{ since: string; category: string; type: "boolean"; default: false; description: string; }'. src/main/parser.js(61,9): error TS2345: Argument of type 'PropertyDescriptor | undefined' is not assignable to parameter of type 'PropertyDescriptor & ThisType'. Type 'undefined' is not assignable to type 'PropertyDescriptor & ThisType'. Type 'undefined' is not assignable to type 'PropertyDescriptor'. diff --git a/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts b/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts index 48364c6a592..0f233e5e574 100644 --- a/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts +++ b/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts @@ -23,7 +23,7 @@ x( // come comment // some other comment -// @anohter +// @another x(); diff --git a/tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts b/tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts new file mode 100644 index 00000000000..55cbf3821a6 --- /dev/null +++ b/tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts @@ -0,0 +1,20 @@ +// https://github.com/Microsoft/TypeScript/issues/25379 + +interface Map { + // ... +} + +export type ImmutableTypes = IImmutableMap; + +export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; + +export interface IImmutableMap> extends Map { + set(key: K, value: T[K]): IImmutableMap; +} + +export type ImmutableTypes2 = IImmutableMap2; +type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; +export type ImmutableModel2 = { [K in keyof T]: isImmutableType }; +export interface IImmutableMap2> extends Map { + set(key: K, value: T[K]): IImmutableMap2; +} diff --git a/tests/cases/compiler/duplicatePackage_globalMerge.ts b/tests/cases/compiler/duplicatePackage_globalMerge.ts new file mode 100644 index 00000000000..6a4ff68ca42 --- /dev/null +++ b/tests/cases/compiler/duplicatePackage_globalMerge.ts @@ -0,0 +1,21 @@ +// @noImplicitReferences: true + +// @Filename: /src/index.ts +import * as React from 'react'; +export var x = 1 +// @Filename: /tests/index.ts +import * as React from 'react'; +export var y = 2 + +// @Filename: /tests/node_modules/@types/react/package.json +{ "name": "@types/react", "version": "16.4.6" } +// @Filename: /tests/node_modules/@types/react/index.d.ts + +// @Filename: /node_modules/@types/react/package.json +{ "name": "@types/react", "version": "16.4.6" } +// @Filename: /node_modules/@types/react/index.d.ts +declare global { } + +// @Filename: /src/bug25410.ts +import { x } from './index' +import { y } from '../tests/index' diff --git a/tests/cases/compiler/exportAssignedNamespaceIsVisibleInDeclarationEmit.ts b/tests/cases/compiler/exportAssignedNamespaceIsVisibleInDeclarationEmit.ts new file mode 100644 index 00000000000..cee17c95acb --- /dev/null +++ b/tests/cases/compiler/exportAssignedNamespaceIsVisibleInDeclarationEmit.ts @@ -0,0 +1,10 @@ +// @declaration: true +// @filename: thing.d.ts +declare namespace Foo { + export interface Bar {} + export function f(): Bar; +} +export = Foo; +// @filename: index.ts +import { f } from "./thing"; +export const thing = f(); \ No newline at end of file diff --git a/tests/cases/compiler/importUsedAsTypeWithErrors.ts b/tests/cases/compiler/importUsedAsTypeWithErrors.ts new file mode 100644 index 00000000000..36df311bbfe --- /dev/null +++ b/tests/cases/compiler/importUsedAsTypeWithErrors.ts @@ -0,0 +1,7 @@ +// @filename: test.ts +export interface T { + value: string +} + +// @filename: main.ts +export const a: import("./test") = null; diff --git a/tests/cases/compiler/requireOfJsonFileWithoutEsModuleInterop.ts b/tests/cases/compiler/requireOfJsonFileWithoutEsModuleInterop.ts new file mode 100644 index 00000000000..d3020c553ae --- /dev/null +++ b/tests/cases/compiler/requireOfJsonFileWithoutEsModuleInterop.ts @@ -0,0 +1,16 @@ +// @module: commonjs +// @moduleResolution: node +// @target:es2017 +// @strict: true +// @resolveJsonModule: true +// @outdir: out/ +// @fullEmitPaths: true + +// @Filename: file1.ts +import * as test from "./test.json" + +// @Filename: test.json +{ + "a": true, + "b": "hello" +} \ No newline at end of file diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment27.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment27.ts new file mode 100644 index 00000000000..71963749f1a --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment27.ts @@ -0,0 +1,11 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: a.js +// mixed prototype-assignment+function declaration +function C() { this.p = 1; } +C.prototype = { q: 2 }; + +const c = new C() +c.p +c.q diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignment28.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignment28.ts new file mode 100644 index 00000000000..5a9ffd3e415 --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignment28.ts @@ -0,0 +1,15 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: a.js +// mixed prototype-assignment+class declaration +class C { constructor() { this.p = 1; } } +// Property assignment does nothing. +// You have to use Object.defineProperty(C, "prototype", { q: 2 }) +// and that only works on classes with no superclass. +// (Object.defineProperty isn't recognised as a JS special assignment right now.) +C.prototype = { q: 2 }; + +const c = new C() +c.p +c.q diff --git a/tests/cases/fourslash/declarationMapsEnableMapping_NoInline.ts b/tests/cases/fourslash/declarationMapsEnableMapping_NoInline.ts deleted file mode 100644 index a17f7afcdd8..00000000000 --- a/tests/cases/fourslash/declarationMapsEnableMapping_NoInline.ts +++ /dev/null @@ -1,34 +0,0 @@ -/// -// @BaselineFile: declarationMapsGeneratedMapsEnableMapping_NoInline.baseline -// @outDir: ./dist -// @inlineSourceMap: true -// @declaration: true -// @declarationMap: true -// @Filename: index.ts -// @emitThisFile: true -////export class Foo { -//// member: string; -//// /*2*/methodName(propName: SomeType): void {} -//// otherMethod() { -//// if (Math.random() > 0.5) { -//// return {x: 42}; -//// } -//// return {y: "yes"}; -//// } -////} -//// -////export interface SomeType { -//// member: number; -////} -// @Filename: mymodule.ts -////import * as mod from "/dist/index"; -////const instance = new mod.Foo(); -////instance.[|/*1*/methodName|]({member: 12}); - -verify.baselineGetEmitOutput(/*insertResultIntoVfs*/ true); -verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan -verify.goToType("1", "2"); // getTypeDefinitionAtPosition -goTo.marker("1"); -verify.goToDefinitionIs("2"); // getDefinitionAtPosition -goTo.implementation(); // getImplementationAtPosition -verify.caretAtMarker("2"); \ No newline at end of file diff --git a/tests/cases/fourslash/declarationMapsEnableMapping_NoInlineSources.ts b/tests/cases/fourslash/declarationMapsEnableMapping_NoInlineSources.ts deleted file mode 100644 index 4760bbc628d..00000000000 --- a/tests/cases/fourslash/declarationMapsEnableMapping_NoInlineSources.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// -// @BaselineFile: declarationMapsGeneratedMapsEnableMapping_NoInlineSources.baseline -// @outDir: ./dist -// @inlineSourceMap: true -// @inlineSources: true -// @declaration: true -// @declarationMap: true -// @Filename: index.ts -// @emitThisFile: true -////export class Foo { -//// member: string; -//// /*2*/methodName(propName: SomeType): void {} -//// otherMethod() { -//// if (Math.random() > 0.5) { -//// return {x: 42}; -//// } -//// return {y: "yes"}; -//// } -////} -//// -////export interface SomeType { -//// member: number; -////} -// @Filename: mymodule.ts -////import * as mod from "/dist/index"; -////const instance = new mod.Foo(); -////instance.[|/*1*/methodName|]({member: 12}); - -verify.baselineGetEmitOutput(/*insertResultIntoVfs*/ true); -verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan -verify.goToType("1", "2"); // getTypeDefinitionAtPosition -goTo.marker("1"); -verify.goToDefinitionIs("2"); // getDefinitionAtPosition -goTo.implementation(); // getImplementationAtPosition -verify.caretAtMarker("2"); \ No newline at end of file diff --git a/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping.ts b/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping.ts deleted file mode 100644 index 42e08f8a27f..00000000000 --- a/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// -// @BaselineFile: declarationMapsGeneratedMapsEnableMapping.baseline -// @outDir: ./dist -// @declaration: true -// @declarationMap: true -// @Filename: index.ts -// @emitThisFile: true -////export class Foo { -//// member: string; -//// /*2*/methodName(propName: SomeType): void {} -//// otherMethod() { -//// if (Math.random() > 0.5) { -//// return {x: 42}; -//// } -//// return {y: "yes"}; -//// } -////} -//// -////export interface SomeType { -//// member: number; -////} -// @Filename: mymodule.ts -////import * as mod from "/dist/index"; -////const instance = new mod.Foo(); -////instance.[|/*1*/methodName|]({member: 12}); - -verify.baselineGetEmitOutput(/*insertResultIntoVfs*/ true); -verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan -verify.goToType("1", "2"); // getTypeDefinitionAtPosition -goTo.marker("1"); -verify.goToDefinitionIs("2"); // getDefinitionAtPosition -goTo.implementation(); // getImplementationAtPosition -verify.caretAtMarker("2"); diff --git a/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping2.ts b/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping2.ts deleted file mode 100644 index 261122c1e8e..00000000000 --- a/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping2.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// -// @BaselineFile: declarationMapsGeneratedMapsEnableMapping2.baseline -// @outDir: ./dist -// @sourceMap: true -// @sourceRoot: /tests/cases/fourslash/ -// @declaration: true -// @declarationMap: true -// @Filename: index.ts -// @emitThisFile: true -////export class Foo { -//// member: string; -//// /*2*/methodName(propName: SomeType): void {} -//// otherMethod() { -//// if (Math.random() > 0.5) { -//// return {x: 42}; -//// } -//// return {y: "yes"}; -//// } -////} -//// -////export interface SomeType { -//// member: number; -////} -// @Filename: mymodule.ts -////import * as mod from "/dist/index"; -////const instance = new mod.Foo(); -////instance.[|/*1*/methodName|]({member: 12}); - -verify.baselineGetEmitOutput(/*insertResultIntoVfs*/ true); -verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan -verify.goToType("1", "2"); // getTypeDefinitionAtPosition -goTo.marker("1"); -verify.goToDefinitionIs("2"); // getDefinitionAtPosition -goTo.implementation(); // getImplementationAtPosition -verify.caretAtMarker("2"); diff --git a/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping3.ts b/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping3.ts deleted file mode 100644 index cd90793358e..00000000000 --- a/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping3.ts +++ /dev/null @@ -1,34 +0,0 @@ -/// -// @BaselineFile: declarationMapsGeneratedMapsEnableMapping3.baseline -// @outDir: ./dist -// @sourceRoot: /tests/cases/fourslash/ -// @declaration: true -// @declarationMap: true -// @Filename: index.ts -// @emitThisFile: true -////export class Foo { -//// member: string; -//// /*2*/methodName(propName: SomeType): void {} -//// otherMethod() { -//// if (Math.random() > 0.5) { -//// return {x: 42}; -//// } -//// return {y: "yes"}; -//// } -////} -//// -////export interface SomeType { -//// member: number; -////} -// @Filename: mymodule.ts -////import * as mod from "/dist/index"; -////const instance = new mod.Foo(); -////instance.[|/*1*/methodName|]({member: 12}); - -verify.baselineGetEmitOutput(/*insertResultIntoVfs*/ true); -verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan -verify.goToType("1", "2"); // getTypeDefinitionAtPosition -goTo.marker("1"); -verify.goToDefinitionIs("2"); // getDefinitionAtPosition -goTo.implementation(); // getImplementationAtPosition -verify.caretAtMarker("2"); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 5ee7ef31be4..81cb387b73d 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -271,6 +271,7 @@ declare namespace FourSlashInterface { baselineCurrentFileBreakpointLocations(): void; baselineCurrentFileNameOrDottedNameSpans(): void; baselineGetEmitOutput(insertResultsIntoVfs?: boolean): void; + getEmitOutput(expectedOutputFiles: ReadonlyArray): void; baselineQuickInfo(): void; nameOrDottedNameSpanTextIs(text: string): void; outliningSpansInCurrentFile(spans: Range[]): void; diff --git a/tests/cases/fourslash/goToDefinitionLabels.ts b/tests/cases/fourslash/goToDefinitionLabels.ts index 3736d9207ee..62b6ab54a62 100644 --- a/tests/cases/fourslash/goToDefinitionLabels.ts +++ b/tests/cases/fourslash/goToDefinitionLabels.ts @@ -12,7 +12,7 @@ verify.goToDefinition({ 1: "label1Definition", 2: "label2Definition", - // labels accross function boundaries + // labels across function boundaries 3: "label1Definition", // undefined label 4: [] diff --git a/tests/cases/fourslash/importNameCodeFix_reExport.ts b/tests/cases/fourslash/importNameCodeFix_reExport.ts new file mode 100644 index 00000000000..0cd2fd40209 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFix_reExport.ts @@ -0,0 +1,20 @@ +/// + +// @Filename: /a.ts +////export default function foo(): void {} + +// @Filename: /b.ts +////export { default } from "./a"; + +// @Filename: /user.ts +////[|foo;|] + +goTo.file("/user.ts"); +verify.importFixAtPosition([ +`import foo from "./a"; + +foo;`, +`import foo from "./b"; + +foo;`, +]); diff --git a/tests/cases/fourslash/declarationMapGoToDefinition.ts b/tests/cases/fourslash/server/declarationMapGoToDefinition.ts similarity index 93% rename from tests/cases/fourslash/declarationMapGoToDefinition.ts rename to tests/cases/fourslash/server/declarationMapGoToDefinition.ts index a83fd7e8396..15f49b1e1b9 100644 --- a/tests/cases/fourslash/declarationMapGoToDefinition.ts +++ b/tests/cases/fourslash/server/declarationMapGoToDefinition.ts @@ -1,40 +1,40 @@ -/// -// @Filename: index.ts -////export class Foo { -//// member: string; -//// /*2*/methodName(propName: SomeType): void {} -//// otherMethod() { -//// if (Math.random() > 0.5) { -//// return {x: 42}; -//// } -//// return {y: "yes"}; -//// } -////} -//// -////export interface SomeType { -//// member: number; -////} -// @Filename: indexdef.d.ts.map -////{"version":3,"file":"indexdef.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;IACI,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"} -// @Filename: indexdef.d.ts -////export declare class Foo { -//// member: string; -//// methodName(propName: SomeType): void; -//// otherMethod(): { -//// x: number; -//// y?: undefined; -//// } | { -//// y: string; -//// x?: undefined; -//// }; -////} -////export interface SomeType { -//// member: number; -////} -//////# sourceMappingURL=indexdef.d.ts.map -// @Filename: mymodule.ts -////import * as mod from "./indexdef"; -////const instance = new mod.Foo(); -////instance.[|/*1*/methodName|]({member: 12}); - -verify.goToDefinition("1", "2"); +/// +// @Filename: index.ts +////export class Foo { +//// member: string; +//// /*2*/methodName(propName: SomeType): void {} +//// otherMethod() { +//// if (Math.random() > 0.5) { +//// return {x: 42}; +//// } +//// return {y: "yes"}; +//// } +////} +//// +////export interface SomeType { +//// member: number; +////} +// @Filename: indexdef.d.ts.map +////{"version":3,"file":"indexdef.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;IACI,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"} +// @Filename: indexdef.d.ts +////export declare class Foo { +//// member: string; +//// methodName(propName: SomeType): void; +//// otherMethod(): { +//// x: number; +//// y?: undefined; +//// } | { +//// y: string; +//// x?: undefined; +//// }; +////} +////export interface SomeType { +//// member: number; +////} +//////# sourceMappingURL=indexdef.d.ts.map +// @Filename: mymodule.ts +////import * as mod from "./indexdef"; +////const instance = new mod.Foo(); +////instance.[|/*1*/methodName|]({member: 12}); + +verify.goToDefinition("1", "2"); diff --git a/tests/cases/fourslash/server/declarationMapsEnableMapping_NoInline.ts b/tests/cases/fourslash/server/declarationMapsEnableMapping_NoInline.ts new file mode 100644 index 00000000000..f85993e7084 --- /dev/null +++ b/tests/cases/fourslash/server/declarationMapsEnableMapping_NoInline.ts @@ -0,0 +1,83 @@ +/// + +// @Filename: /tsconfig.json +////{ +//// "compilerOptions": { +//// "outDir": "./dist", +//// "inlineSourceMap": true, +//// "declaration": true, +//// "declarationMap": true, +//// "newLine": "lf", +//// }, +//// "files": ["/index.ts"], +////} + +// @Filename: /index.ts +// @emitThisFile: true +////export class Foo { +//// member: string; +//// /*2*/methodName(propName: SomeType): void {} +//// otherMethod() { +//// if (Math.random() > 0.5) { +//// return {x: 42}; +//// } +//// return {y: "yes"}; +//// } +////} +//// +////export interface SomeType { +//// member: number; +////} + +// @Filename: /mymodule.ts +////import * as mod from "/dist/index"; +////const instance = new mod.Foo(); +////instance.[|/*1*/methodName|]({member: 12}); + +// @Filename: /dist/index.js +////"use strict"; +////exports.__esModule = true; +////var Foo = /** @class */ (function () { +//// function Foo() { +//// } +//// Foo.prototype.methodName = function (propName) { }; +//// Foo.prototype.otherMethod = function () { +//// if (Math.random() > 0.5) { +//// return { x: 42 }; +//// } +//// return { y: "yes" }; +//// }; +//// return Foo; +////}()); +////exports.Foo = Foo; +//////# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBO0lBQUE7SUFTQSxDQUFDO0lBUEcsd0JBQVUsR0FBVixVQUFXLFFBQWtCLElBQVMsQ0FBQztJQUN2Qyx5QkFBVyxHQUFYO1FBQ0ksSUFBSSxJQUFJLENBQUMsTUFBTSxFQUFFLEdBQUcsR0FBRyxFQUFFO1lBQ3JCLE9BQU8sRUFBQyxDQUFDLEVBQUUsRUFBRSxFQUFDLENBQUM7U0FDbEI7UUFDRCxPQUFPLEVBQUMsQ0FBQyxFQUFFLEtBQUssRUFBQyxDQUFDO0lBQ3RCLENBQUM7SUFDTCxVQUFDO0FBQUQsQ0FBQyxBQVRELElBU0M7QUFUWSxrQkFBRyJ9 + +// @Filename: /dist/index.d.ts.map +////{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"} + +// @Filename: /dist/index.d.ts +////export declare class Foo { +//// member: string; +//// methodName(propName: SomeType): void; +//// otherMethod(): { +//// x: number; +//// y?: undefined; +//// } | { +//// y: string; +//// x?: undefined; +//// }; +////} +////export interface SomeType { +//// member: number; +////} +//////# sourceMappingURL=index.d.ts.map + +goTo.file("/index.ts"); +verify.getEmitOutput(["/dist/index.js", "/dist/index.d.ts.map", "/dist/index.d.ts"]); + +verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan +verify.goToType("1", "2"); // getTypeDefinitionAtPosition +goTo.marker("1"); +verify.goToDefinitionIs("2"); // getDefinitionAtPosition +goTo.implementation(); // getImplementationAtPosition +verify.caretAtMarker("2"); diff --git a/tests/cases/fourslash/server/declarationMapsEnableMapping_NoInlineSources.ts b/tests/cases/fourslash/server/declarationMapsEnableMapping_NoInlineSources.ts new file mode 100644 index 00000000000..83ef95f2f4a --- /dev/null +++ b/tests/cases/fourslash/server/declarationMapsEnableMapping_NoInlineSources.ts @@ -0,0 +1,84 @@ +/// + +// @Filename: /tsconfig.json +////{ +//// "compilerOptions": { +//// "outDir": "./dist", +//// "inlineSourceMap": true, +//// "inlineSources": true, +//// "declaration": true, +//// "declarationMap": true, +//// "newLine": "lf", +//// }, +//// "files": ["/index.ts"], +////} + +// @Filename: /index.ts +// @emitThisFile: true +////export class Foo { +//// member: string; +//// /*2*/methodName(propName: SomeType): void {} +//// otherMethod() { +//// if (Math.random() > 0.5) { +//// return {x: 42}; +//// } +//// return {y: "yes"}; +//// } +////} +//// +////export interface SomeType { +//// member: number; +////} + +// @Filename: /mymodule.ts +////import * as mod from "/dist/index"; +////const instance = new mod.Foo(); +////instance.[|/*1*/methodName|]({member: 12}); + +// @Filename: /dist/index.js +////"use strict"; +////exports.__esModule = true; +////var Foo = /** @class */ (function () { +//// function Foo() { +//// } +//// Foo.prototype.methodName = function (propName) { }; +//// Foo.prototype.otherMethod = function () { +//// if (Math.random() > 0.5) { +//// return { x: 42 }; +//// } +//// return { y: "yes" }; +//// }; +//// return Foo; +////}()); +////exports.Foo = Foo; +//////# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBO0lBQUE7SUFTQSxDQUFDO0lBUEcsd0JBQVUsR0FBVixVQUFXLFFBQWtCLElBQVMsQ0FBQztJQUN2Qyx5QkFBVyxHQUFYO1FBQ0ksSUFBSSxJQUFJLENBQUMsTUFBTSxFQUFFLEdBQUcsR0FBRyxFQUFFO1lBQ3JCLE9BQU8sRUFBQyxDQUFDLEVBQUUsRUFBRSxFQUFDLENBQUM7U0FDbEI7UUFDRCxPQUFPLEVBQUMsQ0FBQyxFQUFFLEtBQUssRUFBQyxDQUFDO0lBQ3RCLENBQUM7SUFDTCxVQUFDO0FBQUQsQ0FBQyxBQVRELElBU0M7QUFUWSxrQkFBRyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBjbGFzcyBGb28ge1xuICAgIG1lbWJlcjogc3RyaW5nO1xuICAgIG1ldGhvZE5hbWUocHJvcE5hbWU6IFNvbWVUeXBlKTogdm9pZCB7fVxuICAgIG90aGVyTWV0aG9kKCkge1xuICAgICAgICBpZiAoTWF0aC5yYW5kb20oKSA+IDAuNSkge1xuICAgICAgICAgICAgcmV0dXJuIHt4OiA0Mn07XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHt5OiBcInllc1wifTtcbiAgICB9XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgU29tZVR5cGUge1xuICAgIG1lbWJlcjogbnVtYmVyO1xufSJdfQ== + +// @Filename: /dist/index.d.ts.map +////{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"} + +// @Filename: /dist/index.d.ts +////export declare class Foo { +//// member: string; +//// methodName(propName: SomeType): void; +//// otherMethod(): { +//// x: number; +//// y?: undefined; +//// } | { +//// y: string; +//// x?: undefined; +//// }; +////} +////export interface SomeType { +//// member: number; +////} +//////# sourceMappingURL=index.d.ts.map + +goTo.file("/index.ts"); +verify.getEmitOutput(["/dist/index.js", "/dist/index.d.ts.map", "/dist/index.d.ts"]); + +verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan +verify.goToType("1", "2"); // getTypeDefinitionAtPosition +goTo.marker("1"); +verify.goToDefinitionIs("2"); // getDefinitionAtPosition +goTo.implementation(); // getImplementationAtPosition +verify.caretAtMarker("2"); diff --git a/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping.ts b/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping.ts new file mode 100644 index 00000000000..c8ea0f74a43 --- /dev/null +++ b/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping.ts @@ -0,0 +1,82 @@ +/// + +// @Filename: /tsconfig.json +////{ +//// "compilerOptions": { +//// "outDir": "./dist", +//// "declaration": true, +//// "declarationMap": true, +//// "newLine": "lf", +//// }, +//// "files": ["/index.ts"], +////} + +// @Filename: /index.ts +// @emitThisFile: true +////export class Foo { +//// member: string; +//// /*2*/methodName(propName: SomeType): void {} +//// otherMethod() { +//// if (Math.random() > 0.5) { +//// return {x: 42}; +//// } +//// return {y: "yes"}; +//// } +////} +//// +////export interface SomeType { +//// member: number; +////} + +// @Filename: /mymodule.ts +////import * as mod from "/dist/index"; +////const instance = new mod.Foo(); +////instance.[|/*1*/methodName|]({member: 12}); + +// @Filename: /dist/index.js +////"use strict"; +////exports.__esModule = true; +////var Foo = /** @class */ (function () { +//// function Foo() { +//// } +//// Foo.prototype.methodName = function (propName) { }; +//// Foo.prototype.otherMethod = function () { +//// if (Math.random() > 0.5) { +//// return { x: 42 }; +//// } +//// return { y: "yes" }; +//// }; +//// return Foo; +////}()); +////exports.Foo = Foo; +//// + +// @Filename: /dist/index.d.ts.map +////{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"} + +// @Filename: /dist/index.d.ts +////export declare class Foo { +//// member: string; +//// methodName(propName: SomeType): void; +//// otherMethod(): { +//// x: number; +//// y?: undefined; +//// } | { +//// y: string; +//// x?: undefined; +//// }; +////} +////export interface SomeType { +//// member: number; +////} +//////# sourceMappingURL=index.d.ts.map + +goTo.file("/index.ts"); +verify.getEmitOutput(["/dist/index.js", "/dist/index.d.ts.map", "/dist/index.d.ts"]); + +verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan +verify.goToType("1", "2"); // getTypeDefinitionAtPosition +goTo.marker("1"); +verify.goToDefinitionIs("2"); // getDefinitionAtPosition +goTo.implementation(); // getImplementationAtPosition +verify.caretAtMarker("2"); diff --git a/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping2.ts b/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping2.ts new file mode 100644 index 00000000000..7799d61e2ae --- /dev/null +++ b/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping2.ts @@ -0,0 +1,87 @@ +/// + +// @Filename: /tsconfig.json +////{ +//// "compilerOptions": { +//// "outDir": "./dist", +//// "sourceMap": true, +//// "sourceRoot": "/", +//// "declaration": true, +//// "declarationMap": true, +//// "newLine": "lf", +//// }, +//// "files": ["/index.ts"], +////} + +// @Filename: /index.ts +// @emitThisFile: true +////export class Foo { +//// member: string; +//// /*2*/methodName(propName: SomeType): void {} +//// otherMethod() { +//// if (Math.random() > 0.5) { +//// return {x: 42}; +//// } +//// return {y: "yes"}; +//// } +////} +//// +////export interface SomeType { +//// member: number; +////} + +// @Filename: /mymodule.ts +////import * as mod from "/dist/index"; +////const instance = new mod.Foo(); +////instance.[|/*1*/methodName|]({member: 12}); + +// @Filename: /dist/index.js.map +////{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;AAAA;IAAA;IASA,CAAC;IAPG,wBAAU,GAAV,UAAW,QAAkB,IAAS,CAAC;IACvC,yBAAW,GAAX;QACI,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;YACrB,OAAO,EAAC,CAAC,EAAE,EAAE,EAAC,CAAC;SAClB;QACD,OAAO,EAAC,CAAC,EAAE,KAAK,EAAC,CAAC;IACtB,CAAC;IACL,UAAC;AAAD,CAAC,AATD,IASC;AATY,kBAAG"} + +// @Filename: /dist/index.js +////"use strict"; +////exports.__esModule = true; +////var Foo = /** @class */ (function () { +//// function Foo() { +//// } +//// Foo.prototype.methodName = function (propName) { }; +//// Foo.prototype.otherMethod = function () { +//// if (Math.random() > 0.5) { +//// return { x: 42 }; +//// } +//// return { y: "yes" }; +//// }; +//// return Foo; +////}()); +////exports.Foo = Foo; +//////# sourceMappingURL=index.js.map + +// @Filename: /dist/index.d.ts.map +////{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"} + +// @Filename: /dist/index.d.ts +////export declare class Foo { +//// member: string; +//// methodName(propName: SomeType): void; +//// otherMethod(): { +//// x: number; +//// y?: undefined; +//// } | { +//// y: string; +//// x?: undefined; +//// }; +////} +////export interface SomeType { +//// member: number; +////} +//////# sourceMappingURL=index.d.ts.map + +goTo.file("/index.ts"); +verify.getEmitOutput(["/dist/index.js.map", "/dist/index.js", "/dist/index.d.ts.map", "/dist/index.d.ts"]); + +verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan +verify.goToType("1", "2"); // getTypeDefinitionAtPosition +goTo.marker("1"); +verify.goToDefinitionIs("2"); // getDefinitionAtPosition +goTo.implementation(); // getImplementationAtPosition +verify.caretAtMarker("2"); diff --git a/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping3.ts b/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping3.ts new file mode 100644 index 00000000000..5785b595440 --- /dev/null +++ b/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping3.ts @@ -0,0 +1,83 @@ +/// + +// @Filename: /tsconfig.json +////{ +//// "compilerOptions": { +//// "outDir": "./dist", +//// "sourceRoot": "/", +//// "declaration": true, +//// "declarationMap": true, +//// "newLine": "lf", +//// }, +//// "files": ["/index.ts"], +////} + +// @Filename: /index.ts +// @emitThisFile: true +////export class Foo { +//// member: string; +//// /*2*/methodName(propName: SomeType): void {} +//// otherMethod() { +//// if (Math.random() > 0.5) { +//// return {x: 42}; +//// } +//// return {y: "yes"}; +//// } +////} +//// +////export interface SomeType { +//// member: number; +////} + +// @Filename: /mymodule.ts +////import * as mod from "/dist/index"; +////const instance = new mod.Foo(); +////instance.[|/*1*/methodName|]({member: 12}); + +// @Filename: /dist/index.js +////"use strict"; +////exports.__esModule = true; +////var Foo = /** @class */ (function () { +//// function Foo() { +//// } +//// Foo.prototype.methodName = function (propName) { }; +//// Foo.prototype.otherMethod = function () { +//// if (Math.random() > 0.5) { +//// return { x: 42 }; +//// } +//// return { y: "yes" }; +//// }; +//// return Foo; +////}()); +////exports.Foo = Foo; +//// + +// @Filename: /dist/index.d.ts.map +////{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"} + +// @Filename: /dist/index.d.ts +////export declare class Foo { +//// member: string; +//// methodName(propName: SomeType): void; +//// otherMethod(): { +//// x: number; +//// y?: undefined; +//// } | { +//// y: string; +//// x?: undefined; +//// }; +////} +////export interface SomeType { +//// member: number; +////} +//////# sourceMappingURL=index.d.ts.map + +goTo.file("/index.ts"); +verify.getEmitOutput(["/dist/index.js", "/dist/index.d.ts.map", "/dist/index.d.ts"]); + +verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan +verify.goToType("1", "2"); // getTypeDefinitionAtPosition +goTo.marker("1"); +verify.goToDefinitionIs("2"); // getDefinitionAtPosition +goTo.implementation(); // getImplementationAtPosition +verify.caretAtMarker("2");